<%option explicit%>
<!DOCTYPE html>
<html>
<head><title>ADO - List Database Records</title></head>
<body>
<%
dim conn,rs,x
set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath("/db/database.mdb"))
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM tblGuestBook",conn
%>

<h2>List Database Table</h2>
<p>Click on a button to modify a record.</p>

<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<%
for each x in rs.Fields
      response.write("<th>" & ucase(x.name) & "</th>")
next
%>

</tr>
<%do until rs.EOF%>
<tr bgcolor="#f0f0f0">
<form method="post" action="demo_db_edit.asp" target="_blank">
<%
for each x in rs.Fields
      if x.name="no" then%>

           <td><input type="submit" name="no" value="<%=x.value%>"></td>
      <%else%>
           <td><%Response.Write(x.value)%> </td>
      <%end if
next
%>

</form>
<%rs.MoveNext%>
</tr>
<%
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

</table>

<p><a href="showaspcode.asp?source=demo_db_list">View source on how to list a database table in an HTML table</a></p>
<p><b>Note:</b> If you click on a button in the "no" column a new page will open. On the new page you may look at the source on how to create input fields based on the fields from one record in the database table.</p>
</body>
</html>