Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys, I am trying to connect to a mySql database through my visual studio application. My connection string is as follows.

SQL
sConnString = @"Server=localhost;Port=3306;Database=test;Uid=username;Pwd=password;";


I get the following error:

Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Any ideas what I'm doing wrong?


Thanks in advance guys.
Posted

You are not telling it what driver to use. It doesn't know how to connect.

First you need to decide if you are using ODBC or ADO.NET to talk to the database.

Then you need to install the ODBC[^] or ADO.NET[^] driver.

Then you need to follow the instructions that come with the driver to connect. Typically something like:
C#
var conn = new MySqlConnection("my connection string");
 
Share this answer
 
Comments
frostcox 12-Jun-14 16:36pm    
Thank you sir, I think it was just too long a day, I followed your links and it works like a treat. Thanks again.
You might want the provider:
http://dev.mysql.com/downloads/connector/net/[^]
 
Share this answer
 
There are many solutions suggested by Google[^]. Try some of them first.
 
Share this answer
 
Downloaded and installed the MySQL Connector/Net from the MySQL official website
http://dev.mysql.com/downloads/connector/net/6.1.html

Open Visual Studio and click on the new project and give the project a name; it will open the new project, then click on the solution explorer (F4); right-click on "Reference" to add a new reference into the project. Add a reference for those two .dll files to the project (MySql.dll (Win apps), MySql.web.dll (Web apps)).




]]>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900