Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 didn't configure anything past that.. like I normally would with DSN).

 

And here is my 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 you'll have any ideas?

 

 

 

thanks for any pointers!

 

Lee

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...