|
First, your app, since it's running on a shared system with other applications, should NEVER change system-wide settings like this.
Second, why do you want to do this?
|
|
|
|
|
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.
|
|
|
|