asp.net to mySql connection
There are times when you want to connect to a mySql database from your asp.net code. By default the drivers for mySql are not packaged with asp.net so you need to include an external dll into your project.
this dll contains all the necessary code required to provide the abstraction that .net developers are used to with while working on ADO.NET. You add the dll into your project and next moment you are creating instances of
MySqlConnection, MySqlDataReader and hence forth things are same as you would do with your mssql database connection code.
The dll is available to download at the end of this article.
How to use
- download MySql.data.dll
- copy it to the bin folder of your application (use windows explorer to browse to the project location (bin folder as it’s generally not visible in Visual Studio)
- Add a reference of the said dll into your project
using MySql.Data.MySqlClient;inside your code
- Make objects of
MySqlConnection, MySqlDataReader, MySqlCommandand use them as you would use
SqlConnection, SqlDataReader, SqlCommandrespectively