|
-
Apr 15th, 2010, 10:16 AM
#1
Thread Starter
Lively Member
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()
-
Apr 15th, 2010, 10:24 AM
#2
Re: database connection closes my form automatically
Did you try an place this in a Try Catch block and show the error message?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 15th, 2010, 10:49 AM
#3
Thread Starter
Lively Member
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.
-
Apr 15th, 2010, 10:54 AM
#4
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 15th, 2010, 11:10 AM
#5
Thread Starter
Lively Member
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
-
Apr 15th, 2010, 11:22 AM
#6
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
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 15th, 2010, 12:02 PM
#7
Thread Starter
Lively Member
Re: database connection closes my form automatically
Thanks, I appreciate the help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|