Gå direkte til hovedinnholdet

Windows Hosting (Plesk) Hjelp

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) & "
end if

Set oRs = nothing
Set oConn = nothing



mikeb1's Avatar
Connecting to mySQL database

5 svar

Last posted about 1 year ago.

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

1 svar

Last posted about 4 years ago.

overkill452's Avatar
Connecting to a Remote MySQL Database

21 svar

Last posted about 3 years ago.

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

2 svar

Last posted about 3 years ago.

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

8 svar

Last posted over 4 years ago.

Ser du ikke det du er ute etter? Søk i Fellesskapet