Getting vb.net setup to use oledb to connect to mysql.. i keep getting this error :/

trend

Well-known member
Joined
Oct 12, 2004
Messages
171
Hello, I have been reading up on how to get vb.net to use oledb to access a mysql server.

I saw a post saying I can use this:
http://dev.mysql.com/downloads/connector/net/1.0.html

So I installed that (I didnt configure anything past that.. like I normally would with DSN).

And here is my code:
Code:
Dim FirstName

Dim MyConnection As OleDbConnection

Dim connString As String = "Provider=MySQLProv;" & "DRIVER={MySQL ODBC 3.51 Driver};" & _

"SERVER=192.168.254.7;" & "DATABASE=test;" & "UID=picture;" & _

"PASSWORD=frame;" & "OPTION=3"

MyConnection = New OleDbConnection(connString)

MyConnection.Open()

MyCommand.Connection = MyConnection

Dim MyCommand As New OleDbCommand("SELECT * FROM Users;", MyConnection)

Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader()

While MyReader.Read

Lastname.Text = MyReader("Lastname")

FirstName = MyReader("Firstname")

 Address.Text = MyReader("Address")

End While

MyConnection.Close()

and the program errors out saying:



An unhandled exception of type System.InvalidOperationException occurred in system.data.dll

Additional information: The MySQLProv provider is not registered on the local machine.


Do youll have any ideas?



thanks for any pointers!

Lee
 
Go and download the MySql Connector/Net from:

http://dev.mysql.com/downloads/connector/net/1.0.html

Install the product, and add a reference to the MySql.Data.Dll file to your project.

From then on, you can use MySqlConnection/MySqlCommand/MySqlDataReader/MySqlDataAdapter in exactly the wsame way that you use OleDBConnection/OleDbCommand etc..

when you .Open() a MySqlConnection, you will need to pass various pieces of information into it. An example connection string might be:

"Server=YourMysqlServer;username=DatabaseUser;password=GoAwayAndDie;database=YourDatabaseName;persist security info=true;compress=true;pooling=true"

B.
 
Ahh.. got it.. I just had to add:
Imports MySql.Data.MySqlClient

and make sure the pointer was setup correctly
 
Back
Top