trend Posted March 22, 2005 Posted March 22, 2005 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 Quote
penfold69 Posted March 23, 2005 Posted March 23, 2005 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. Quote
trend Posted March 23, 2005 Author Posted March 23, 2005 hmm.. I do that and I get a lot of "undefined" errors.. Here is a screenshot :/ http://webpages.charter.net/trend/error.GIF Am I not including something? thanks! Lee Quote
trend Posted March 24, 2005 Author Posted March 24, 2005 Ahh.. got it.. I just had to add: Imports MySql.Data.MySqlClient and make sure the pointer was setup correctly Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.