|
If you want to persist anyway, get prepared for some P/Invoking.
There isnt a function SetDisplayColorDepth() or so; instead you need access to the following
Win32 functions (below is C# syntax):
[DllImport("user32.dll")]
public static extern int EnumDisplaySettings (string deviceName,
int modeNum, ref DEVMODE1 devMode );
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(ref DEVMODE1 devMode, int flags);
for which you also would need a number of constants and the DEVMODE1 struct; then add
some C# or VB code to obtain the supported settings, find the one you want, and set it.
If you havent done P/Invoke before, dont bother. Try something simpler first.
|
|
|
|
|
Hi,
I wonder if its possible to query the tables in a dataset same as we do with the database tables!
I have loaded my dataset with almost 10 tables and now want to extract data from four of those tables to display everything in a datagrid!
But i couldn't find a way as how easily it can be done?
In other words i was just trying to avoid the SQL JOINS ... so i opted for dataset manipulations..
any help in this regard will be appreciated!!!
Thanks
|
|
|
|
|
Well, if you wanted to do it the same way as you would from SQL, you'd STILL be using the JOIN's. But since you can't do it using the same SQL syntax, no.
What's so hard about learning the JOIN clause anyway? Just learn it and get it overwith. You'll need it in the future and it's much easier than the way you want to do it now, so why wait?
|
|
|
|
|
Yeah thanks for the good advice and i have already started working with JOINs somehow .. But still are there any ways to filter data from two or more tables of a dataset using some criteria?
Also, when i have populated my datagrid with three or more tables how can i update data in all three if some changes occur in datagrid?
thanks
|
|
|
|
|
My problem is that in the program that I am writing I cannot save the changes to database after I load the tables from it.
Dim connstr As String = "provider=microsoft.jet.oledb.4.0;" & _
" DATA SOURCE = megas.mdb"
Dim sqlstr As String = " select * from megas "
Dim dtb As New DataTable
‘--------------------------------------------------------------
Private Sub btnload_Click(…) Handles btnload.Click
dtb.Clear()
Dim dataadapter As New OleDb.OleDbDataAdapter(sqlstr, connstr)
dataadapter.Fill(dtb)
dataadapter.Dispose()
dgdisplay1.DataSource = dtb
End Sub
‘-----------------------------------------------------------------
Private Sub btnsave_Click (…) Handles btnsave.Click
Dim changes As Integer
Dim dataadapter As New OleDb.OleDbDataAdapter(sqlstr, connstr)
Dim commandbuilder As New OleDb.OleDbCommandBuilder(dataadapter)
changes = dataadapter.Update(dtb)
dataadapter.Dispose()
If changes > 0 Then
MsgBox("SAVED ")
Else
MsgBox("not saved")
End If
End Sub
I load the table form the database and nothing goes wrong with this part, but when I want to save the changes and I click the save btn , that is what I get
“An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll “
What am I doing wrong? And why should I be getting this?
Thank you.
• Thanks for the previous help from Dave Kreskowiak and Naji Kotob +mackay, it really helped, especially that article.
|-|■~F~|-|■
|
|
|
|
|
The OleDb.OleDbException class is created whenever the .NET Framework Data Provider for OLE DB encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) OleDbException always contains at least one instance of OleDbError. -an explanation from msdn
--the most common cause of this is because of a missing data source
as what is written on your code:
Dim connstr As String = "provider=microsoft.jet.oledb.4.0;" & _
" DATA SOURCE = megas.mdb"
the "DATA SOURCE" should be replaced by "DataSource"(no spaces)
and make sure that megas.mdb is properly installed on the odbc connection.
|
|
|
|
|
Hi,
general exceptions (I guess OleDbException qualifies) often contain an "internal exception".
You wont see it if you just look at Exception.Message, but you would see it
when looking at Exception.ToString() so I recommend everyone to always log or display
Exception.ToString(); it is longer by the fact that it provides more information.
I am not sure but expect this to apply to your situation too.
|
|
|
|
|
I am trying to figure out how to retrieve the Event Sources from an event log using WMI. I am using the list to populate a combobox in the main program. I am including the function that I am using to return a comma-separated list of sources that will be put into an array to add to the combo-box ItemRange property. (I realize there may be a better way to do that part, but I am new to this and any constructive criticism will be appreciated.)
When I run the program, the error is that the Strings.Len(arrSourceNames) must be greater than 0. I can't figure out why the "sources()" property from WMI is not populating.
I have used this code on another function to grab the list of Event Logs (application, system, etc) that are available on the computer (with some modifications, of course). It works in that capacity. I think the problem lies somewhere in pulling the array of sources from the WMI query.
Here is the code...
Private Function GetEventSources(ByVal _computerName As String, ByVal _logFile As String) As String<br />
Dim arrSourceNames As String = ""<br />
<br />
If _computerName <> My.Computer.Name.ToString Then<br />
Dim wmiScope As New ManagementScope("\\" & _computerName & "\root\cimv2")<br />
wmiScope.Connect()<br />
<br />
Dim wmiQuery As New ObjectQuery("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName = '" & _logFile & "'")<br />
Dim searcher As New ManagementObjectSearcher(wmiScope, wmiQuery)<br />
Dim queryCollection As ManagementObjectCollection = searcher.Get()<br />
For Each m As ManagementObject In queryCollection<br />
For Each source As String In m("Sources()")<br />
arrSourceNames = arrSourceNames & source & ","<br />
Next<br />
Next<br />
Else<br />
Dim wmiQuery As New ObjectQuery("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName = '" & _logFile & "'")<br />
Dim searcher As New ManagementObjectSearcher(wmiQuery)<br />
Dim queryCollection As ManagementObjectCollection = searcher.Get()<br />
For Each m As ManagementObject In queryCollection<br />
For Each source As String In m("Sources()")<br />
arrSourceNames = arrSourceNames & source & ","<br />
Next<br />
Next<br />
<br />
End If<br />
<br />
Return Strings.Left(arrSourceNames, Strings.Len(arrSourceNames) - 1)<br />
<br />
End Function
Any help to figure this out will be appreciated greatly.
Jonathan Tyler
|
|
|
|
|
jontyler wrote: For Each source As String In m("Sources()")
I'm willing to bet that there is not a property in your returned Win32_NTEventLogFile objects that is called "Sources()". It's probably called "Sources" though.
|
|
|
|
|
Thanks Dave...
You were correct, there is no Sources() property, but there is a Sources property. It was confusing looking at the MSDN content about the Win32_NTEventlogFile class because it shows it as Sources(). Oh well. The other thing I learned, once I fixed that problem, is that I wasn't passing an actual logfile name to the function. I was sending cboList.SelectedValue and should have been sending cboList.Text. Once I made that change, everything worked much better. It also helped me to encapsulate that code into a procedure that I can call in the form load as well as any other time the items changed.
Thanks for your help with this.
Jonathan Tyler
|
|
|
|
|
Hi to all
i am new programmer my proble is i am created one
Service Request report which fetch the data from the
database now when i click on one button i want to convert it into that of the pdf file.
pl. suggest me
Thanks
|
|
|
|
|
If you are using ReportViewer then your user should be able to export to pdf. If you are talking about the ability to generate pdf from your code, then you need 3rd party tools.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
how can i simulate right button click in a VB6 program
plzzzzzzzzzzzzzzzzzzzz help
and plz do tell how can i simulate left button click with its single click and double click properties in VB6
FARAH
|
|
|
|
|
Are you trying to send this mouse click to your own code?? Or to an outside application??
In your own code, you do'nt have to simulate a mouse click. How you reorganize your code to allow calling it from other places depends on what your code is doing in its mouse click event.
If an outside app, look into getting the window handle of the control you want to send the mouse click to and use the Win32 API function SendMessage to send a properly formatted mouse window message to the target window.
|
|
|
|
|
Private Sub Button1_Click(... )
dim f as new form1
f.MdiParent = Me
f.show()
ens sub
this code allways creates a new mdi child i need only one instance at a time. how can i prevent duplicating form1 ?
i am using vs2003
thanks
|
|
|
|
|
Hi,
In the main form:
Private Sub Button1_Click(... )
if bLoaded = True then Exit Sub
dim f as new form1
f.MdiParent = Me
bLoaded = True
f.show()
ens sub
'... in form1.Closed
bLoaded = False
.... in a module
Friend bLoaded as Boolean = False
hope this helps
|
|
|
|
|
thanks 4 ur reply!
is there any other way to load a form other than
"dim f as new form1" this way ?
|
|
|
|
|
Hi,
You could simply execute Form.Show() [VB2005], but form1 is a class and I prefer to create an instance of it explicitly using the New Keywork
regards
|
|
|
|
|
there is no Show() member function found for form1. is it bcause of vb2003?
|
|
|
|
|
No, there isn't. The advice was bad. There is another way of creating an instance of a form, but involves Reflection and a lot more code than just myForm = New MyFormClass .
|
|
|
|
|
If you want to use the control that is used in the windows Task Manager to show the task and status for an application then follow these steps:
1.) Add a ListView to your form
2.) Set the "View" property to "Details"
3.) Go to the "Columns" property and click in the text field next to the word "Columns" where it says "(Collection)" and then click on the small button marked "..."
4.) Add a ColumnHeader by clicking the "Add" button
5.) Name your ColumnHeader
6.) Type the title that you want on the ColumnHeader in the text field next to the word "Text" and your done
OPTIONAL
LabelEdit Property - If this property is set to true the user can double-click an item in the listview to be able to change it.
|
|
|
|
|
Is there a question in here, or just a piece of advice ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
when i am running my application created from vb.net the following error is display
" System.IO.FileNotFoundException: Could not load file or assembly 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' "
i am using adod control
setup also installed in that machine , the os in the machine is windows xp home edition service pack 2
solution pls
sathish
-- modified at 23:57 Friday 20th July, 2007
|
|
|
|
|
Googling for "Could not load file or assembly 'ADODB" gives lots of hits, starting
with this one.[^]
I would suggest you read it; seems you are not the first with that problem.
|
|
|
|
|
I am working in VB.net 2003.
The project is to convert some fortran code to vb.
I have a set of fortran routines and one function.
I have converted them to the best of my abilty but have a few remaining problems: (at least I hope so)
Problem 1^^^^^^^^^^^^^^^^^^
"Value of type 'Double' cannot be converted to '2-dimensional array of Double"
This is the line raising the error: eight lines after the "180:"
Call DBNFAC(W(IWP, 1), NWROW, N, ILB, IUB, IFLAG)
Problem 2^^^^^^^^^^^^^^^^^^
What should be done with the Dim statements from fortran.
they are commented out just above the line:
'***FIRST EXECUTABLE STATEMENT DBINT4
Here is the code. Any clues would be most appriciated.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sub DBINT4(ByVal X() As Double, ByVal Y() As Double, ByVal NDATA As Integer, ByVal IBCL As Integer, ByVal IBCR As Integer, ByVal FBCL As Double, ByVal FBCR As Double, ByVal KNTOPT As Integer, ByVal T() As Double, ByVal BCOEF() As Double, ByVal N As Integer, ByVal K As Integer, ByVal W(,) As Double)
'***BEGIN PROLOGUE DBINT4
'***DATE WRITTEN 800901 (YYMMDD)
'***REVISION DATE 820801 (YYMMDD)
'***CATEGORY NO. E1A
'***KEYWORDS B-SPLINE,DATA FITTING,DOUBLE PRECISION,INTERPOLATION,
' SPLINE
'***AUTHOR AMOS, D. E., (SNLA)
'***PURPOSE Computes the B-representation of a cubic spline
' which interpolates data (X(I),Y(I)),I=1,NDATA.
'***DESCRIPTION
'
' Written by D. E. Amos, August, 1979.
'
' References
' SAND-78-1968
'
' A Practical Guide to Splines by C. de Boor, Applied
' Mathematics Series 27, Springer, 1979.
'
' SIAM J. Numerical Analysis, 14, No. 3, June, 1977, pp.441-472.
'
' Abstract **** a double precision routine ****
'
' DBINT4 computes the B representation (T,BCOEF,N,K) of a
' cubic spline (K=4) which interpolates data (X(I),Y(I)),
' I=1,NDATA. Parameters IBCL, IBCR, FBCL, FBCR allow the
' specification of the spline first or second derivative at
' both X(1) and X(NDATA). When this data is not specified
' by the problem, it is common practice to use a natural
' spline by setting second derivatives at X(1) and X(NDATA)
' to zero (IBCL=IBCR=2,FBCL=FBCR=0.0). The spline is defined
' on T(4) .LE. X .LE. T(N+1) with (ordered) interior knots at
' X(I) values where N=NDATA+2. The knots T(1),T(2),T(3) lie to
' the left of T(4)=X(1) and the knots T(N+2), T(N+3), T(N+4)
' lie to the right of T(N+1)=X(NDATA) in increasing order. If
' no extrapolation outside (X(1),X(NDATA)) is anticipated, the
' knots T(1)=T(2)=T(3)=T(4)=X(1) and T(N+2)=T(N+3)=T(N+4)=
' T(N+1)=X(NDATA) can be specified by KNTOPT=1. KNTOPT=2
' selects a knot placement for T(1), T(2), T(3) to make the
' first 7 knots symmetric about T(4)=X(1) and similarly for
' T(N+2), T(N+3), T(N+4) about T(N+1)=X(NDATA). KNTOPT=3
' allows the user to make his own selection, in increasing
' order, for T(1), T(2), T(3) to the left of X(1) and T(N+2),
' T(N+3), T(N+4) to the right of X(NDATA) in the work array
' W(1) through W(6). In any case, the interpolation on
' T(4) .LE. X .LE. T(N+1) by using function DBVALU is unique
' for given boundary conditions.
'
' DBINT4 calls DBSPVD, DBNFAC, DBNSLV, D1MACH, XERROR
'
' Description of Arguments
'
' Input X,Y,FBCL,FBCR,W are double precision
' X - X vector of abscissae of length NDATA, distinct
' and in increasing order
' Y - Y vector of ordinates of length NDATA
' NDATA - number of data points, NDATA .GE. 2
' IBCL - selection parameter for left boundary condition
' IBCL = 1 constrain the first derivative at
' X(1) to FBCL
' = 2 constrain the second derivative at
' X(1) to FBCL
' IBCR - selection parameter for right boundary condition
' IBCR = 1 constrain first derivative at
' X(NDATA) to FBCR
' IBCR = 2 constrain second derivative at
' X(NDATA) to FBCR
' FBCL - left boundary values governed by IBCL
' FBCR - right boundary values governed by IBCR
' KNTOPT - knot selection parameter
' KNTOPT = 1 sets knot multiplicity at T(4) and
' T(N+1) to 4
' = 2 sets a symmetric placement of knots
' about T(4) and T(N+1)
' = 3 sets T(I)=W(I) and T(N+1+I)=W(3+I),I=1,3
' where W(I),I=1,6 is supplied by the user
' W - work array of dimension at least 5*(NDATA+2)
' If KNTOPT=3, then W(1),W(2),W(3) are knot values to
' the left of X(1) and W(4),W(5),W(6) are knot
' values to the right of X(NDATA) in increasing
' order to be supplied by the user
'
' Output T,BCOEF are double precision
' T - knot array of length N+4
' BCOEF - B spline coefficient array of length N
' N - number of coefficients, N=NDATA+2
' K - order of spline, K=4
'
' Error Conditions
' Improper input is a fatal error
' Singular system of equations is a fatal error
'***REFERENCES D.E. AMOS, *COMPUTATION WITH SPLINES AND B-SPLINES*,
' SAND78-1968, SANDIA LABORATORIES, MARCH 1979.
' C. DE BOOR, *PACKAGE FOR CALCULATING WITH B-SPLINES*,
' SIAM JOURNAL ON NUMERICAL ANALYSIS, VOLUME 14, NO. 3,
' JUNE 1977, PP. 441-472.
' C. DE BOOR, *A PRACTICAL GUIDE TO SPLINES*, APPLIED
' MATHEMATICS SERIES 27, SPRINGER, 1979.
'***ROUTINES CALLED D1MACH,DBNFAC,DBNSLV,DBSPVD,XERROR
'***END PROLOGUE DBINT4
'
'
Dim I As Integer
Dim IFLAG As Integer
Dim ILB As Integer
Dim ILEFT As Integer
Dim IT As Integer
Dim IUB As Integer
Dim IW As Integer
Dim IWP As Integer
Dim J As Integer
Dim JW As Integer
Dim NDM As Integer
Dim NP As Integer
Dim NWROW As Integer
Dim TOL As Double
Dim TXN As Double
Dim TX1 As Double
Dim VNIKX(,) As Double
Dim WDTOL As Double
Dim WORK() As Double
Dim XL As Double
Dim D1MACH() As Double
'Dim X(1), Y(1), T(1), BCOEF(1), W(5, 1), VNIKX(4, 4), WORK(15)
'***FIRST EXECUTABLE STATEMENT DBINT4
WDTOL = D1MACH(4)
TOL = Sqrt(WDTOL)
If (NDATA < 2) Then GoTo 200
NDM = NDATA - 1
For I = 1 To NDM
If (X(I) >= X(I + 1)) Then GoTo 210
10: Next I
If (IBCL < 1 Or IBCL > 2) Then GoTo 220
If (IBCR < 1 Or IBCR > 2) Then GoTo 230
If (KNTOPT < 1 Or KNTOPT > 3) Then GoTo 240
K = 4
N = NDATA + 2
NP = N + 1
For I = 1 To NDATA
T(I + 3) = X(I)
20: Next I
Select Case KNTOPT
Case 1 : GoTo 30
Case 2 : GoTo 50
Case 3 : GoTo 90
End Select
' SET UP KNOT ARRAY WITH MULTIPLICITY 4 AT X(1) AND X(NDATA)
30: REM
For I = 1 To 3
T(4 - I) = X(1)
T(NP + I) = X(NDATA)
40: Next I
GoTo 110
' SET UP KNOT ARRAY WITH SYMMETRIC PLACEMENT ABOUT END POINTS
50: REM
If (NDATA > 3) Then GoTo 70
XL = (X(NDATA) - X(1)) / 3.0
For I = 1 To 3
T(4 - I) = T(5 - I) - XL
T(NP + I) = T(NP + I - 1) + XL
60: Next I
GoTo 110
70: REM
TX1 = X(1) + X(1)
TXN = X(NDATA) + X(NDATA)
For I = 1 To 3
T(4 - I) = TX1 - X(I + 1)
T(NP + I) = TXN - X(NDATA - I)
80: Next I
GoTo 110
' SET UP KNOT ARRAY LESS THAN X(1) AND GREATER THAN X(NDATA) TO BE
' SUPPLIED BY USER IN WORK LOCATIONS W(1) THROUGH W(6) WHEN KNTOPT=3
90: REM
For I = 1 To 3
T(4 - I) = W(4 - I, 1)
'If 1 >= I - 1 Then max0 = 1 Else max0 = I - 1
JW = Max(1, I - 1)
IW = I + 2 Mod 5 + 1
T(NP + I) = W(IW, JW)
If (T(4 - I) > T(5 - I)) Then GoTo 250
If (T(NP + I) < T(NP + I - 1)) Then GoTo 250
100: Next I
110: REM
'
For I = 1 To 5
For J = 1 To N
W(I, J) = 0.0
120: Next J
130: Next I
' SET UP LEFT INTERPOLATION POINT AND LEFT BOUNDARY CONDITION FOR
' RIGHT LIMITS
IT = IBCL + 1
Call DBSPVD(T, K, IT, X(1), K, 4, VNIKX, WORK)
IW = 0
If (Abs(VNIKX(3, 1)) < TOL) Then IW = 1
For J = 1 To 3
W(J + 1, 4 - J) = VNIKX(4 - J, IT)
W(J, 4 - J) = VNIKX(4 - J, 1)
140: Next J
BCOEF(1) = Y(1)
BCOEF(2) = FBCL
' SET UP INTERPOLATION EQUATIONS FOR POINTS I=2 TO I=NDATA-1
ILEFT = 4
If (NDM < 2) Then GoTo 170
For I = 2 To NDM
ILEFT = ILEFT + 1
Call DBSPVD(T, K, 1, X(I), ILEFT, 4, VNIKX, WORK)
For J = 1 To 3
W(J + 1, 3 + I - J) = VNIKX(4 - J, 1)
150: Next J
BCOEF(I + 1) = Y(I)
160: Next I
' SET UP RIGHT INTERPOLATION POINT AND RIGHT BOUNDARY CONDITION FOR
' LEFT LIMITS(ILEFT IS ASSOCIATED WITH T(N)=X(NDATA-1))
170: REM
IT = IBCR + 1
Call DBSPVD(T, K, IT, X(NDATA), ILEFT, 4, VNIKX, WORK)
JW = 0
If (Abs(VNIKX(2, 1)) < TOL) Then JW = 1
For J = 1 To 3
W(J + 1, 3 + NDATA - J) = VNIKX(5 - J, IT)
W(J + 2, 3 + NDATA - J) = VNIKX(5 - J, 1)
180: Next J
BCOEF(N - 1) = FBCR
BCOEF(N) = Y(NDATA)
' SOLVE SYSTEM OF EQUATIONS
ILB = 2 - JW
IUB = 2 - IW
NWROW = 5
IWP = IW + 1
Call DBNFAC(W(IWP, 1), NWROW, N, ILB, IUB, IFLAG)
If (IFLAG = 2) Then GoTo 190
Call DBNSLV(W(IWP, 1), NWROW, N, ILB, IUB, BCOEF)
Exit Sub
'
'
190: REM
Call XERROR(" DBINT4, THE SYSTEM OF EQUATIONS IS SINGULAR", 45, 2, 1)
Exit Sub
200: REM
Call XERROR(" DBINT4, NDATA IS LESS THAN 2", 30, 2, 1)
Exit Sub
210: REM
Call XERROR(" DBINT4, X VALUES ARE NOT DISTINCT OR NOT ORDERED", 50, 2, 1)
Exit Sub
220: REM
Call XERROR(" DBINT4, IBCL IS NOT 1 OR 2", 28, 2, 1)
Exit Sub
230: REM
Call XERROR(" DBINT4, IBCR IS NOT 1 OR 2", 28, 2, 1)
Exit Sub
240: REM
Call XERROR(" DBINT4, KNTOPT IS NOT 1, 2, OR 3", 34, 2, 1)
Exit Sub
250: REM
Call XERROR(" DBINT4, KNOT INPUT THROUGH W ARRAY IS NOT ORDEREDPROPERLY", 60, 2, 1)
End Sub
|
|
|
|
|