<%@LANGUAGE="VBSCRIPT" %> <% 'Connect to MySQL from ASP 'For this to work on the server: 'You must install (on the server) a MySQL ODBC Driver 'At the time of this writing, there is: 'MySQL ODBC 3.51.12 Driver and MySQL ODBC 5.0 Driver Alpha Release '3.51.12 will work on cgtmm2 Option Explicit Response.Buffer = True On Error Resume Next 'Dimension variables Dim oConn, oRS, SQL 'Set up DB connection Set oConn = Server.CreateObject("ADODB.Connection") 'Set up Recordset Set oRS = Server.CreateObject("ADODB.Recordset") ' Create ODBC connection string & open connection ' You will need to change northwind to yourDB name oConn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=northwind; UID=yourID;PASSWORD=yourPass" oConn.Open(sConnection) 'Prepare SQL statement SQL = "SELECT FirstName, LastName FROM Employees" 'Execute the query and store result in oRS Set oRS = oConn.Execute(SQL) 'oRS.EOF means the next row is the End Of File. 'Each value in oRS.Fields("") is a column name in the table. 'Writing oRS.Fields("columnName") will return the value of that cell in the DB. while not oRS.EOF Response.Write(oRS.Fields("LastName") & ", " & oRS.Fields("FirstName") & "
") oRS.MoveNext() wend 'Close all object references oRS.Close Set oRS = Nothing oConn.Close Set oConn = Nothing %>