Loop through and list records from a database with classic ASP

A basic example showing how to loop through records in a database using classic ASP.

Dim strDbConnection
Dim objConn
Dim objRS
Dim strSQL
strDbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\test.mdb;"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open(strDbConnection)
strSQL = "SELECT fullName, birthDate FROM persons"
Set objRS = objConn.Execute(strSQL)
If objRS.EOF Then
  Response.Write("No items found")
Else
  Do While Not objRS.EOF
    Response.Write(objRS.Fields("birthDate").value & ", ")
    Response.Write(objRS.Fields("fullName").value & "<br />")
    objRS.MoveNext()
  Loop
End If
objRS.Close()
Set objRS = Nothing
objConn.Close()
Set objConn = Nothing

Search

Feeds

RSS 2.0 feed All content
RSS 2.0 feed ajax
RSS 2.0 feed asp
RSS 2.0 feed aspnet
RSS 2.0 feed bicycle
RSS 2.0 feed copenhagen
RSS 2.0 feed databases
RSS 2.0 feed denmark
RSS 2.0 feed diy
RSS 2.0 feed dotnet
RSS 2.0 feed html
RSS 2.0 feed japan
RSS 2.0 feed javascript
RSS 2.0 feed modding
RSS 2.0 feed photography
RSS 2.0 feed utilities
RSS 2.0 feed vbscript