The problem of connecting to mysql from vs2010

I am trying to connect to mysql using c # in vs2010. I installed the .net 6.3.5 connector version from mysql site. I am trying to use 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 I get 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 know why this is happening?

Thanks for any thoughts.

+3
source share
1 answer

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

<add name="mySql"
     connectionString="Server=localhost;Database=mydb;Uid=User;Pwd=mypass;" 
     providerName="MySql.Data.MySqlClient"/>
+3
source

Source: https://habr.com/ru/post/1771940/


All Articles