Connection to MySQL with ASP

When you need to access a MySQL database, you need an ADO database connection.
It can be set up as follows:

<%
SQLserveradr="[server]"
SQLdatabase="[database]"
SQLlogin="[user name]"
SQLpassword="password"

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

conStr = "driver={MySql};server="& SQLserveradr &";database="& SQLdatabase
conStr = conStr & ";uid="& SQLlogin &";pwd="& SQLpassword & ";OPTION=3"

Conn.Open conStr
%>

OPTION - the part of the connection string may vary according to the context in which you need your connection, usually either 3 or 16386 is recommended - read more in the documentation for MySQL's ODBC connector.

Article from the support category: ASP & ASP.NET