%@ Language=VBScript %> <% option explicit %>
<% dim conn,rs dim fname,connstr,sql 'this example looks at pulling information out of the database Set conn = Server.CreateObject("ADODB.Connection") fname = server.mappath("students.mdb") connstr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & fname conn.open connstr,"","" Set rs = Server.CreateObject("ADODB.Recordset") ' Substitute in form parameters into the query string sql = "select * from students;" rs.Open sql, conn, 1, 1 dim fcount 'following pulls the number of fields out of the recordset... fcount = rs.fields.count response.write ("
Total Fields: " & fcount) dim rcount 'following gets the number of records... rcount = rs.recordcount 'now put the info in the presentation... response.write ("
Total Records: " & rcount) dim i rs.movefirst do while not rs.eof response.write ("
--------------New Record------------
")
'here we use the recordcount in for-next loop
'note that arrays tend to be 0 referenced
for i = 0 to rs.fields.count - 1
response.write (rs.fields(i).name)
response.write (" --- ")
Response.Write (rs.fields(i).value)
response.write ("
")
'Close the loop iterating records
next
rs.MoveNext
loop
rs.Close
set rs = Nothing
set conn = Nothing
%>