【发布时间】:2014-09-15 17:25:51
【问题描述】:
我正在尝试使用 c# 连接到 MySql 数据库。但是我收到了这个错误。
Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
我的 C# 代码
Connection con = new Connection();
Recordset rs = new Recordset();
string conStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
con.Open(conStr); // Here its throwing the error
连接字符串:
<add name="DefaultConnection"
connectionString="DRIVER={MySQL ODBC 5.2w Driver};Server=localhost;Database=laundrydatabase;Uid=root;Pwd=123"
/>
我正在使用
mysql-connector-net-6.6.5
MySQL ODBC 5.1 Driver}
【问题讨论】:
-
您说您使用的是 ODBC 5.1 驱动程序,但在连接字符串中您说的是 5.2。你可以试试不在连接字符串中指定驱动程序吗?
-
@Vivekh:你为什么不试试 mysql .Net/C# 驱动程序而不是 ODBC 驱动程序。
-
是的,我已经尝试过了,我现在正在与他们合作,但我只想知道为什么我无法通过 ODBC 连接。
标签: c# mysql connection-string