How to connect to MySQL from ASP

Before you do this you need to create a database. This can be done in the following way: How do I create a database?


With the following connection string you connect to your MySQL database. In most ASP websites you will have to put this in the web.config file. The server name can be found out in the following way: Where can I find the server on which my MySQL databases are running?

By means of ODBC 5.1

Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;

by ODBC 5.3

Dim DTB_Conn

Set DTB_Conn = Server.CreateObject("ADODB.Connection")

DTB_Conn.Open "Provider=MSDASQL;Driver={MySQL ODBC 5.3 ANSI Driver};Server=mysql.myhostingpartner.co.uk;Database=;User=;Password=;Option=3;"



Via web.config

connectionString="Server=myServerAddress;Database=MyDataBase;User=MyUser;Password=myPassword;"

(Obsolete)

through ODBC 5.1

Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;