ASP Database Connection

Below is a simple asp connection script with a query designed to show all the tables held within your database.

Copy and paste this into a asp page, change the connection details to those specified and watch the database return the results.

You can continue to modify this script to run other quires on your database and return the results.

'Dim statement to declare variables
Dim sConnection, objConn , objRS
'set database connection variables
username = "enter your username here"
password = "enter your password here"
database = "enter your database name here"
host = "enter your host here"
'assign a value to the sConnection variable
sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER="&host&"; DATABASE="&database&"; UID="&username&";PASSWORD="&password&"; OPTION=3"
'create the ADODB object
Set objConn = Server.CreateObject("ADODB.Connection")
'open the connection
'excecute mysql query
Set objRS = objConn.Execute("show tables")
'loop through the mysql result and display its output
do until objRS.EOF
  for each x in objRS.Fields
    Response.Write(x.value & "<br />")
'close and unset variables
Set objRS = Nothing
Set objConn = Nothing