Find connection string for connecting to MySQL Server 5.1.50 using OleDbConnection

两盒软妹~` 提交于 2019-12-24 02:34:14

问题


I am interested how can I find the connection string in order to be able to connect to MySQL Server 5.1.50 using OleDbConnection(C#).

I used this auto generated string (after adding new data source in Visual Studio):

server=localhost;User Id=MyID;password=MyPassword;database=MyDatabase 

but I always get the same error message:

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

I have tried different providers but neither of them seems to work.


回答1:


Is there a reason you aren't using the MySQL .NET connector? Anyways, I think you need to add Provider=MySQL Provider; to your connection string.

try this as your connection string:

Provider=MySQL Provider;server=localhost;User Id=MyID;password=MyPassword;database=MyDatabase; 

The MySQL.NET connector fully implements the ADO.NET interface. Every command is identical to using the System.Data.SqlClient namespace.



来源:https://stackoverflow.com/questions/5919989/find-connection-string-for-connecting-to-mysql-server-5-1-50-using-oledbconnecti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!