开发者

how to fix this error?vb.net

Here is the screen shot of the vb.net: http://www.mypicx.com/12132009/ers/

And here is my code:

Dim connectionString As String = "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=my school;" '
        Dim conn As New OdbcConnection(connectionString)
        conn.Open()
        Dim da As New OdbcDataAdapter("SELECT IDNUMBER, LASTNAME, FIRSTNAME, MIDDLENAME COURSE FROM students", conn)


        conn.C开发者_StackOverflowlose()

-All I want to do is to connect wamp server with vb.net, here is the version in wamp server

sql server : 5.1.36


Instead of ODBC I would suggest you downloading the ADO.NET standard driver for MySQL and use it like this:

Dim connectionString As String = "Server=localhost;Database=my school;Uid=myUsername;Pwd=myPassword;"
Using conn As New MySqlConnection(connectionString)
    Using da As New MySqlDataAdapter("SELECT IDNUMBER, LASTNAME, FIRSTNAME, MIDDLENAME COURSE FROM students", conn)
        conn.Open()
        ' Do something with the results

    End Using
End Using


"Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=my school;"

sql server : 5.1.36

You are using the wrong driver, namely one for a MySQL database. Your database is a SQL Server, so another driver is needed; try "Driver={SQL Server}" in the connection string instead (only a wild guess …).


Assuming you're using MySQL 5.1.36 and not SQL Server 5.1.36 (in which case it's really time for an upgrade) then you probably need to install MySQL Connector/NET, these are the drivers that will let you connect to a MySQL database from a .NET application.

You'll then also be able to use the native MySQL data classes, such as MySqlConnection instead of the generic OdbcConnection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜