Connecting to MySQL in .NET June 23, 2008
Posted by tuse in : Technical , 2 commentsAll corporate data is stored in one database or the other. Therefore, one of the most common requirements in application development is to access that data which is already present in a table.
To do so, applications require some form of data access. We chose Open Database Connectivity (ODBC) for the purpose.
Read more about ODBC in the wiki

Ok, so we are going to use the ODBC driver to connect our MySQL Database. But as shown in the figure, we still need the Connector. This may be obtained from the MySQL site here
Version 5.1 is the latest, we use version 3.51
So this Connector helps our application to interact with the database.
An important property that is required while connecting programatically to a database using code in your application is the Connection String.
The connection String for a connect to a MySQL database using MySQL Connector (ODBC 3.51) is -
Driver={MySQL ODBC 3.51 Driver};Server=localhost;
Database=db name; User=username;Password=password;
This can be used with the MySQL ODBC 5.1 too. Just change the Driver name in the connection string.
Here, the server is given as localhost as we have our database on the same computer as the application (remember we used WAMP). If it be on a server, just give the host there.
Note down the connection string, it will be used in all database applications.
