Connecting .NET application to a MySQL Database is as easy as 123

Posted on December 17, 2007 - Filed Under ASP.NET |

By Aurelie A. Peralta

I have a website client that commissioned me to create a website with some portions of it are active server pages that uses a database to display vital informations for its users. I developed the website using ASP.NET technology but immediately after showing him the homepage design of his website, told me to use MySQL for the database. Although it is not the popular choice for an ASP.NET application database, he opted to use MySQL probably because of its low cost in terms of hosting fees. Besides, there is no great deal in granting his request because in .NET, connecting to a MySQL database is as easy as 123.

The first thing to do, of course, is to install a MySQL database and service to your machine. The easiest way so far to do this is to download XAMPP for windows. XAMPP for windows is a complete easy to install package that gives you a complete WAMP platform (Windows Apache MySQL PHP). It has a control panel where you can easily start and stop the Apache, MySQL and other Services included in the package. You can start the MySQL database service from here and then create your database using PHPMyAdmin which will eventually run on the Apache Web Service that comes within it.

Next, you have to download an ODBC connection for MySQL module which is actually given free from the Internet. Install this package to be able to add namespaces needed in the System.Data.ODBC class which will facilitate configuration of your connection string for the application. Once everything above was accomplished, start developing your application the usual way with only having your connection string configured for the MySQL ODBC driver/provider.

Most webhosting packages give MySQL database service for free and now this free database service can now be easily utilized by .NET web developers.

Comments

Leave a Reply