02 March 2008

Connecting to MySQL Database from ASP.Net - Overview

I didn't think it was possible before. I thought only PHP can connect to MySql database. I was so wrong! The steps to connect to MySql database from ASP.Net 2.0 page is pretty simple (I didn't think so previously though), so let me share my experience here then.

There are a few steps to do this:

  1. Install MySql database
    You can install the Community version if you're not feeling rich.
  2. Install PhpMyAdmin or SqlYog or other softwares that can be used to administer MySql database
    I prefer SqlYog that PhpMyAdmin as it's simpler and easier to use, but still let me create my database, tables, columns, run my queries, etc. But if you're requirements are more complex, then maybe you'll need PhpMyAdmin.
  3. Install ASP.Net Mysql Connector
  4. Sometimes even after you install the connector, you still need to add the mysql.dll file to your bin directory (ASP.Net 1.1) or add reference in ASP.Net 2.0
  5. Write your code!