Skip to main content
Help Center

Windows Hosting (Plesk) Help

Connecting to a MySQL Database Using ASP/ADO

This example describes using ASP/ADO to connect to a MySQL Database.

Replace values beginning with your_ with your databases information. Replace mysql.secureserver.net with the database hostname.

<%
Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server

db_server = "mysql.secureserver.net"
db_name = "your_dbusername"
db_username = "your_dbusername"
db_userpassword = "your_dbpassword"
fieldname = "your_field"
tablename = "your_table"

connectstr = "Driver={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
"
oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

%>

Community Related

mikeb1's Avatar
Connecting to mySQL database

5 Replies

Last posted over 1 year ago.

overkill452's Avatar
Connecting to a Remote MySQL Database

21 Replies

Last posted over 3 years ago.

kerryww's Avatar
Trouble connecting MySql Database from an ASP script

1 Replies

Last posted about 4 years ago.

bennyboy's Avatar
Setting up ASP Schema for MSSQL Database in Plesk

2 Replies

Last posted over 3 years ago.

Coolweb's Avatar
Connecting to a MySQL database with a form.

5 Replies

Last posted over 4 years ago.

Don't see what you are looking for? Search the Community