%@ language=VBScript %>
Option Explicit Response.Buffer = True On Error Resume Next 'A System DSN does NOT need to be set up for this example. '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("Driver={Microsoft Access Driver (*.mdb)};" _ & "DBQ=" & Server.MapPath("db/nwind.mdb")) '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