database connection closes my form automatically
I have a piece of code connecting to my database retrieving data. I was just testing the form on another computer and everytime it loads this specific form it closes the form. Anyone know why it would do that?
You can see the lines I had to comment out in order for the form to NOT close on load. Is there something possibly that needs to be installed on this other computer? running XP pro 32 bit.
Code:
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dr As OleDbDataReader
Dim connectionString As String
Dim sql As String
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb;"
sql = "SELECT * FROM table WHERE ID = (SELECT MAX(ID) FROM table)"
conn = New OleDbConnection(connectionString)
'conn.Open()
comm = New OleDbCommand(sql, conn)
'dr = comm.ExecuteReader()
'conn.Close()
'dr.Close()
comm.Dispose()
conn.Dispose()
Re: database connection closes my form automatically
Did you try an place this in a Try Catch block and show the error message?
Re: database connection closes my form automatically
Thanks! I've never used that before.
I get this error
Could not load file or assembly 'System.EnterpriseServices.Wrapper.dll' or one of its dependencies. The system cannot find the path specified.
Re: database connection closes my form automatically
OK now do you know how to set break points and step though code? That way you can see on what line it fails.
Re: database connection closes my form automatically
no, Iver never done that before. Is it easy to tell me how?
Also, I should say the issue is now fixed. I reinstalled the .net framework 2.0 and I don't get the error anymore. Thank you for telling me about the try/catch block
Re: database connection closes my form automatically
Read here for a starting on degugging.... If you progress in programming you will need to understand how to do this.
http://blogs.msdn.com/sburke/archive...urce-code.aspx
Re: database connection closes my form automatically
Thanks, I appreciate the help!