Link to home
Start Free TrialLog in
Avatar of Smoerble
SmoerbleFlag for Germany

asked on

c#: How to connect to mySQL?

Hi ppl...
I use .NET 1.1. The server is Windows 2003, my dev machine is Win XP.

On both machines the following code is not working:
-------------------
using System.Data.Odbc;
...
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
                         "SERVER=localhost;" +
                         "DATABASE=lrforum;" +
                         "UID=root;" +
                         "PASSWORD=whatever;" +
                         "OPTION=3";
OdbcConnection MyConnection = new OdbcConnection(MyConString);
-------------------
error:
Data source name not found and no default driver specified at System.Data.Odbc.OdbcConnection.Open() at cs.tests.testMySQL.Page_Load...


How can I test if mySQL is installed correctly ?
What is wrong with the code above?

Hope you can help, I am very frustrated right now :(
Avatar of testn
testn

To use that code, you would need to install MySQL ODBC first. But actually I would recommend you to start using MySQL .NET Data PRovider
If you want to stick with your code, you need to download and install this http://dev.mysql.com/downloads/connector/odbc/3.51.html. Download the windows version either as .EXE or .MSI.
Avatar of Smoerble

ASKER

I don't need to stick to my code. But I don't know any other way... Any link where to find  MySQL .NET Data PRovider and any link for a tutorial / example code?
ASKER CERTIFIED SOLUTION
Avatar of Razzie_
Razzie_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, the download from Razzie solved it, thanks a LOT.