我正在尝试使用vs2010中的c#连接到mysql。我从mysql站点安装了6.3.5版本的.net连接器。我尝试使用以下连接字符串 -
<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" />
我收到以下错误 -
An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
然后我将连接字符串更改为 -
<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" />
并收到以下错误 -
The 'MySQLProv' provider is not registered on the local machine.
有谁知道为什么会这样?
感谢您的任何想法。
答案 0 :(得分:3)
看看http://www.connectionstrings.com/mysql。但是,您不应该通过OLEDB提供商。尝试类似:
<add name="mySql"
connectionString="Server=localhost;Database=mydb;Uid=User;Pwd=mypass;"
providerName="MySql.Data.MySqlClient"/>