Using MySQL in ASP.NET

Most web hosts provide more mySQL databases than SQl Server 2005 database. To keep your hosting costs low , you might need to use MySQL in your projects.

To connect to MySQL database
First download the drivers here
Then copy MySql.Data .dll and MySql.Web.dll to your bin directory

The connection string is as follows

<add name="ASPNETDBConnectionString" connectionString = "Server=localhost;User ID=youruserID; Password=yourpassword; Database=databasename"
providerName="MySql.Data.MySqlClient" />

The MySQl Connector 5.2 has built in support for membership provider too. So from inside Visual Studio you can use the ASP.NET configuration to automatically generate the membership schema

Leave a Reply