Results 1 to 6 of 6

Thread: can not fill dataset

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    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.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try adding a semicolon to the end of your connectionstring:
    Dim conString As String = "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=myDatabaseName;"

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471
    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.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  5. #5
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    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

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471
    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
  •  



Click Here to Expand Forum to Full Width