[英]My Sql Connection error Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I am trying to connect to MySql database with c#. 我正在尝试使用c#连接到MySql数据库。 But i am getting this error. 但是我得到这个错误。
Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
My c# code 我的C#代码
Connection con = new Connection();
Recordset rs = new Recordset();
string conStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
con.Open(conStr); // Here its throwing the error
Connection string: 连接字符串:
<add name="DefaultConnection"
connectionString="DRIVER={MySQL ODBC 5.2w Driver};Server=localhost;Database=laundrydatabase;Uid=root;Pwd=123"
/>
I am using 我在用
mysql-connector-net-6.6.5
MySQL ODBC 5.1 Driver}
You have the MySQL ODBC driver 5.1 installed but your connection string says version 5.2. 您已经安装了MySQL ODBC驱动程序5.1,但是您的连接字符串为5.2版。 This means the system cannot find the driver and that is indicated by the second half of the error message. 这意味着系统找不到驱动程序,并且错误消息的后半部分指出了这一点。 the easiest way to fix is to remove the driver reference from connection string: 修复最简单的方法是从连接字符串中删除驱动程序引用:
Server=localhost;Database=laundrydatabase;Uid=root;Pwd=123
Or if you need to specify the driver, fix the reference like this: 或者,如果您需要指定驱动程序,请像这样修复引用:
Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=laundrydatabase;Uid=root;Pwd=123
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.