%@ language=VBScript %>
Option Explicit Response.Buffer = True On Error Resume Next 'Before you can use this, a System DSN needs to be set 'up. Point the DSN at the DB you want to access. 'Dimension variables Dim oConn Dim oRS Dim SQL 'Set up DB connection Set oConn = Server.CreateObject("ADODB.Connection") 'Set up Recordset Set oRS = Server.CreateObject("ADODB.Recordset") 'Open the connection to DB Call oConn.Open("DSN=nwind") 'Prepare SQL statement SQL = "SELECT DISTINCT Title FROM Customers" '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("ContactTitle") & "<br>" & chr(13)) oRS.MoveNext() wend 'Close all object references oRS.Close Set oRS = Nothing oConn.Close Set oConn = Nothing