views:

154

answers:

3

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.Close()

-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

A: 
"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 …).

Konrad Rudolph
I think MySQL is being used. There is no SQL Server version 5.1.36.
Daniel Vassallo
@Daniel: ouch, didn’t pay attention to the version number. Hmm … I still guess that the driver isn’t installed, though.
Konrad Rudolph
+2  A: 

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
Darin Dimitrov
A: 

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.

cxfx