Support Center » Knowledgebase » How to connect to a MySQL database from an ASP / ASP.NET script

How to connect to a MySQL database from an ASP / ASP.NET script



You can connect to MySQL using either the ODBC driver, or the MyOleDB driver.

Using ODBC DSN:

  1. Go to your control panel and click on ODBC
  2. Create the DSN. The DSN will be called "accountname-dsnname", with the account name being your control panel account name.
  3. In your ASP Script use this connection string: "DSN=accountname-dsnname"

We do not recommend using ODBC DSN due to portability issues.

 

Using DSN-less Method:

Use the following connect string to ADODB.Connection object:

"Driver={MySQL ODBC 3.51 Driver}; Server=servername; Database=dbname; UID=username; PWD=password; Option=3"

or

"Driver={MySQL ODBC 5.1 Driver}; Server=servername; Database=dbname; UID=username; PWD=password; Option=3"

Where servername is as indicated on your control panel.

 

The connection string for MyOleDB is as follows:

"Provider=MySqlProv;Data Source=DBName;Password=Password;User ID=UserName;Location=servername"

This method applies to both ASP and ASP.NET scripts.



Article Details
Article ID: 22
Created On: 02 Oct 2004 05:00 AM
 Back
 Login [Lost Password] 
Email:
Password:
Remember Me:
Please note that the login and password to the support area is NOT the same as your hosting control panel login and password
 
 Search
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Downloads | Control Panel User's Guide | Server Status
Language: