|
-
Feb 11th, 2004, 08:56 AM
#1
Thread Starter
Hyperactive Member
can not fill dataset
The following is my code:
Dim sql As String = "Select * From tblStudnet"
Dim conString As String = "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=myDatabaseName"
'Create connection object
Dim connection As OdbcConnection = New OdbcConnection(conString)
connection.open()
msgbox"connected"
'Create data connection object
Dim daStudent As OdbcDataAdapter = New OdbcDataAdapter(sql, connection)
'Create a dataset object and fill with data using data adapter's Fill method
Dim dsStudent As DataSet = New DataSet()
dsStudent.Clear()
daStudent.Fill(dsStudent, "tblNewTable")
I got error at last line:
"An unhandled exception of type 'Microsoft.Data.Odbc.OdbcException' occurred in microsoft.data.odbc.dll
Additional information: System error."
Can you help?
Last edited by Palmtree; Feb 11th, 2004 at 11:05 AM.
-
Feb 11th, 2004, 10:57 AM
#2
Try adding a semicolon to the end of your connectionstring:
Dim conString As String = "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=myDatabaseName;"
-
Feb 11th, 2004, 11:08 AM
#3
Thread Starter
Hyperactive Member
thanks for your reply, Edneeis.
I tried your suggestion, no luck. I added a msgbox after the connection was open, it seems the connection was opened successfully.
-
Feb 11th, 2004, 11:11 AM
#4
Check the stacktrace of the exception to get which line is giving you trouble. Also make sure that you spelled the tablename right and there is no need to clear the dataset since you just created it.
-
Feb 11th, 2004, 11:20 AM
#5
I thought the same thing about clearing it before using, but have seen a few suggestions that it causes greif with binding if you dont.
Check the exception info as Edneeis says, you have a few things you can look at: (slight edit from the help file)
e.Errors(i).Message
e.Errors(i).NativeError.ToString()
e.Errors(i).Source
e.Errors(i).SQLState
-
Feb 11th, 2004, 11:21 AM
#6
Thread Starter
Hyperactive Member
I did it. Thank you so much!
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
|