3

I am trying to connect to mysql using c# in vs2010. I installed the 6.3.5 version of the .net connector from the mysql site. I try using the following connection string -

<add name="mySql" connectionString="Server=localhost;Database=mydb;Uid=User;Pwd=mypass;" providerName="System.Data.OleDb.OleDbConnection, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

and am getting the following error -

An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'.

So I then change the connection string to -

<add name="mySqlTarget" connectionString="Provider=MySQLProv;Server=localhost;Database=mydb;Uid=User;Pwd=mypass;" providerName="System.Data.OleDb.OleDbConnection, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

And get the following error -

The 'MySQLProv' provider is not registered on the local machine.

Does anyone have any idea why this is happening?

thanks for any thoughts.

1 Answer 1

3

Take a look at http://www.connectionstrings.com/mysql. However, you should not go through the OLEDB provider. Try something like:

<add name="mySql"
     connectionString="Server=localhost;Database=mydb;Uid=User;Pwd=mypass;" 
     providerName="MySql.Data.MySqlClient"/>
Sign up to request clarification or add additional context in comments.

2 Comments

yeah - that is what I ended up with. I got my connections mixed up and was trying to use the oledb when I should have been using the mysql connector. thanks
The MySQL .NET Connector is said to be an OLE DB provider, so it should work to use that. This approach seems better because then you don't have to recompile your .NET code when you want to use some other OLE DB compliant DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.