I am trying to connect to MySql database with c#. But i am getting this error.
Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
My c# code
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. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.