<%@ Language=VBScript %> <% option explicit %> List All Students

List of All Students

Using tables to display data from a database...

 

<% 'following is used to maintain a connection for recurring connections 'session variable holds the connection dim conn,rs dim fname,connstr,sql 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 do while not rs.eof %> <% 'Close the loop iterating records rs.MoveNext Loop rs.Close 'note that we do not close the database connection set rs = Nothing conn.close set conn = Nothing %>
Last Name First Address Major
<% Response.Write(rs.fields("lastname")) %> <% Response.Write(rs.fields("firstname")) %> <% Response.Write(rs.fields("address")) %> <% Response.Write(rs.fields("major")) %>