|
Hi I am converting a project fromVB6 to vb.net the following line gives an error, Can anyone tell me how to fix it?
Private Sub Form_Load()
Load(AccessForm)
Load(LeaveMsgForm)
The error I get is:
'Public Event Load(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
|
|
|
|
|
s3rro wrote: Private Sub Form_Load()
You have to change its structure like this:
Private Sub Form_Load(sender as Object,e as System.EventArgs) handles MyBase.Load
'Additional Code here
End Sub
Hope it helps !
AliAmjad(MCP)
|
|
|
|
|
|
I am in the final throws of my development for an app so I have started my testing.
One of my scenarios is a the removal of the SQL Native Client driver (Windows XP). After the uninstall, I attempt to run the app and am always presented with this error message, which is expected as the native client was required.
The problem I have is that I did not write in a message box to display this error!
I've searched through the code to find a rouge msgbox but found nothing that would present this error.
Any suggestions to suppress this so I can present something more friendly?
Here's how i create connection, if needed
<br />
<br />
Try<br />
Using connection As New OdbcConnection(ConnectionString)<br />
Dim command As New OdbcCommand(queryString, connection)<br />
connection.Open()<br />
<br />
Dim reader As OdbcDataReader = command.ExecuteReader()<br />
<br />
While reader.Read()<br />
count = reader(0).ToString<br />
End While<br />
<br />
connection.Close()<br />
reader.Close()<br />
End Using<br />
Catch ex As Exception<br />
SQLERROR = True<br />
WriteErrorLog(ex.ToString)<br />
Exit Sub<br />
<br />
End Try<br />
|
|
|
|
|
I think this is an unhandled exception error message try to use this code to handle it:
Dim withevents ap as AppDomain
Private Sub ap_UnhandledException(ByVal sender As Object, ByVal e As System.UnhandledExceptionEventArgs) Handles ap.UnhandledException
'Additional Code
End Sub
hope it helps !
AliAmjad(MCP)
|
|
|
|
|
Exactly what it was! Thanks for letting me know, YTMND!
|
|
|
|
|
??? I wasn't letting u know that Its an unhandled exception but rather tried to give you the solution.
AliAmjad(MCP)
|
|
|
|
|
If you're running on SQL Server, why are you bothering with the ODBC provider?? It's slower and doesn't use any features or optimizations that are specific to using SQL Server.
|
|
|
|
|
Its the only way i know how to do it programmatically...
|
|
|
|
|
It's not very different from what you already have. You're just using the OdbcXXX classes instead of the SqlXXXX set of classes.
|
|
|
|
|
After I finished converting(with visual studio 2005 automatic convertor) a windows application written in vb.net 2002 to vb.net 2005
I recieved few syntax errors that I did not find a sulution for them yet.
The first one is:
The error line - If TypeOf Me.WorkingTable.Column(i).DataType is Boolean Then
The error message- Expression of type 'system.Type' can never be of type 'Boolean'.
finally worked like this:
If Me.WorkingTable.Columns(i).DataType is GetType(Boolean) Then
-- modified at 12:25 Wednesday 31st October, 2007
|
|
|
|
|
Hi all...
I am using the following code: Shell("cmd.exe /c cscript C:\Projects\TEST\FileMonitor.vbs", AppWinStyle.Hide, True, -1) in vb.net
Now... the FileMonitor.vbs section is a vbscript file that contains code to monitor a folder for any new file creations... when it gets the file i can have cmd prompt display the filepath\filename. Is it possible to send this filename\filepath back to vb.net as i run the Shell("cmd.exe /c cscript C:\Projects\TEST\FileMonitor.vbs", AppWinStyle.Hide, True, -1) in vb.net??? I want add this filename into a variable.
Thank you in advance.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Would it be possible to have the VBS write the filepath/filename to a textfile and then just have the VB app read that?
|
|
|
|
|
You are a geniuse... Thank you... i did not think of that
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
I don't know about genius. I was trying to think of the easiest/laziest way possible
Let me know if you run across any more questions.
|
|
|
|
|
There's several ways of doing this. The 2nd easiest is, like the other person said, to have the script write it to a file.
The 3rd easiest is to rewrite your Shell statement into a .NET Framework Process object and use that to redirect the console output to a stream in your code.
The very easiest way to do this would be to scrap the VBScript part entirely and just use the .NET Frameworks FileSystemWatcher class, which will tell you if a file was created in the folder it's watching and what the new filename is.
|
|
|
|
|
Dave
I seem to have read somewhere that FileSystemWatcher has a problem when too many events hit it too quickly. We looked at it 2 yrs ago and decided to do it manually as we had 1000s of file to process.
|
|
|
|
|
True, if you have a bunch of files being created at once.
|
|
|
|
|
Hi guys.
I wanna pass an event to a sub but i dono how to perform it.
Some thing like this:
Private Sub Event_Performer (ByVal arg1 as ????)<br />
RaiseEvent arg1<br />
End Sub
|
|
|
|
|
Would this help?
http://www.codeproject.com/vb/net/StepByStepEventsInVBNET.asp
|
|
|
|
|
What you really want to accomplish??? why are you doing this !
AliAmjad(MCP)
|
|
|
|
|
You're can not pass an event. You can, however, pass an event arguments object, or EventArgs.
But, depending on what you're really trying to do with this, normally, the only thing that gets the eventargs is the event handler. The handler then picks out what pieces of information it needs and passes those processed pieces to other methods. You would just about never pass an entire eventargs object to a method that is, itself, not an event handler.
It looks like you're trying to raise an event, but the parameters in your header are confusing. What are you really trying to do with this code?? Why does this code exist?
|
|
|
|
|
tnx Guys. I'm implementing and error generator sub that take error code and message from various exeption handlings and it should raise respective events.
|
|
|
|
|
I'm very new to vb.net 2005
Im now the next step of learning and want to connect a Microsort Access database to visual basic.net 2005.
I have tryed to follow an example in Microsoft Visual basic 2005 Reloaded book by Richard A. Johnson. But i'm not getting the same results as he's book?
I designed a database in microsoft access 2007, and saved it in formats 2007 & 2003. (I have tried both formats in tying to connect the database to VB.net 2005).
I connected the database using the 'add new Date Source' in the Data Source window in Visual Basic.net 2005. In the configuration wizard i selected Database, then i select 'new Connection', chose ' Microsoft Access Database File (OLE DB)' as the data source, then added my database. Tested the connection and then clicked 'next'. I saved a copy of the database, selected the database object i wanted in my dataset. I know have a datasource in Vb. I can view all the table and preview the data in the tables......all looking good.
I then click on the datasource and select 'Details', then drag the datasource over onto my vbform. All the fields are displayed ok. I also have a dataset, a bindingSource, a tableAdapter and a BindingNavigator at the bottom on my vbform.
The problem I have, is when I run the program, I can not display the data in the tables (fields)they are empty.
What part did I do wrong and how can I display the data in the database and display it in the vbForm?
Any help will be much appreciated.
Ian Wells
Ian Wells irwells@hotmail.com
|
|
|
|
|
Does this help?
http://www.vbdotnetheaven.com/UploadFile/mahesh/CreateSQLDatabase04252005064419AM/CreateSQLDatabase.aspx
http://www.connectionstrings.com/
Personally I never use the way you are setting up a connection. I find it shakey.
<br />
ConnectionString = "Provider=" + Provider + "Driver=" + Driver + "Server=" + Server + "; Database=" + DB + "; UID=" + UserName + "; PWD=" + Password + ";Trusted_Connection=yes;"<br />
<br />
queryString = "SELECT Names FROM MYTABLE"<br />
<br />
Try<br />
Using connection As New OdbcConnection(ConnectionString)<br />
Dim command As New OdbcCommand(query, connection)<br />
connection.Open()<br />
<br />
Dim reader As OdbcDataReader = command.ExecuteReader()<br />
<br />
While reader.Read()<br />
StringArray(i) = reader(0).ToString<br />
i += 1<br />
End While<br />
<br />
connection.Close()<br />
reader.Close()<br />
End Using<br />
Catch ex As Exception<br />
<br />
End Try<br />
|
|
|
|