tags:

views:

38

answers:

1

When I try to connect to a MySQL Database from my .NET application i keep getting the error:

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

I went to this URL and downloaded/installed the Windows, MSI Installer Connector-ODBC but I am still getting the error. Is there something else I should be doing to get this to work?

This is the connection string I am using:

<add name="sfc" connectionString="DRIVER={MySQL ODBC 5.1 Driver};SERVER=111.111.111.111;PORT=3306;DATABASE=dbname;USER=username;PASSWORD=password;OPTION=0;" />
A: 

Check that the ODBC driver is properly installed (run odbcad32.exe and go to the drivers tab)

Anyway, you should use the native ADO.NET provider rather than the ODBC driver, it's more efficient.

Thomas Levesque
What do I look for in the drivers tab? This is the first time i've ever used MySQL with .net and this was the only way I could get it to work. Can you elaborate on what you mean by "use the native ADO.NET provider rather than the ODBC driver"?
Abe Miessler
Also, when I say "get it to work" i'm talking about on my hosting environment (godaddy). I'm having the problem on my development environment.
Abe Miessler
@Abe Miessler Use http://dev.mysql.com/downloads/connector/net/ instead of the ODBC driver.
nos
what should my connection string look like then? Can I still use a SQLDataSource with that?
Abe Miessler
@Abe, I mean use the MySQLConnection, MySQLCommand etc classes instead of OdbcConnection, OdbcCommand, etc. And yes, you can still use a SqlDataSource with this provider. You need to specify "MySql.Data.MySqlClient" as the provider name
Thomas Levesque
I haven't done anything in codebehind so far and i'd like to keep it that way if possible.
Abe Miessler
You don't need to use any code-behind. You can set the ProviderName directly in the designer
Thomas Levesque