How To Make .Net Programming Languages Say Hello To MySQL?

MySQL took the world of RDBMS by storm as it was one of the first database systems which were full fledged RDBMS with nearly all the important features, completely free of cost and open source. Best part is that it has been constantly upgraded to make it stand on its own in front of already successful commercial database systems like MSSQL Server and ORACLE. While MySQL integrated beautifully with the open source scripting languages, especially php. However, in order for it become a viable and an effective alternative to expensive commercial RDBMS, it had to be made capable enough to communicate with the popular commercial programming languages, especially those belonging to immensely successful and popular .Net platform, which have a natural affinity and native compatibility with the MSSQL Server.

Now the biggest question is how to make our .Net applications talk to MySQL, thereby saving huge license cost one has to spend on MSSQL Server. This is where Open Database Connectivity came into picture; ODBC is a set of standards and rules to create an interface giving an access to the various relational and non relational databases. This standard was introduced with an intention to prevent application programming languages dependent upon a RDBMS of a particular vendor only. Keeping the rules and standards espoused by ODBC, MySQL Connector/ODBC, a set of MySQL ODBC drivers, were created to help .Net based languages communicate with MySQL database.

Following steps are to be followed in order to make your .Net application talk to the MySQL:

  1. First and foremost one should have MySQL installed on their machine, so download MySQL from the MySQL Downloads page.
  2. Create the database and tables, those not familiar with MySQL can look at instructions to create MySQL databases and tables.
  3. Download the Microsoft ODBC.NET driver.
  4. Here is the sample VB.Net code to connect to a MySQL database and extract data from it:
Imports System.Data.Odbc
Dim connectionString As String = "DSN=dataSource;UID=root;PWD=password"
Dim myConnection As Data.Odbc.OdbcConnection
myConnection = New Data.Odbc.OdbcConnection(connectionString)
Dim myCommand As Data.Odbc.OdbcCommand = New     
Data.Odbc.OdbcCommand("SELECT * FROM Table", myConnection)
Dim reader As Data.Odbc.OdbcDataReader = Nothing
reader = myCommand.ExecuteReader()

So if you feel yourself hampered by the top dollar to be paid for the commercial RDBMS then this is the perfect opportunity to break free by using free and opensource products like MySQL and experience the ultimate freedom. Here you need not be bothered about licensing costs and create beautiful and useful software applications. So follow the instructions given here and experience the true happiness which free and opensource software brings.

Author: ucavik