III) Show/View database records:
<%
Set Dbconnection=server.createobject ("ADODB. CONNECTION ")
DBPath = Server.MapPath ("Customer.mdb")
DbConnection. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & DBPath
Establish a connection with the database, with the same.
Sql= "SELECT * from Customer Order by Time DESC"
SET customerlist=dbconnection. EXECUTE (SQL)
%>
Creates an SQL query statement that queries all records from the Customers table, and the order by time DESC indicates "Sorted by time," so that the last added information is displayed on top. The following sentence executes the SQL query and returns the result to the Recordset object customerlist.
<body>
<font size= "5" ><center> database records </center></FONT>
<CENTER>
<table border=1>
<tr>
<td> number </td>
<td> Company Name </td>
<td> Contact person's name </td>
<td> City </td>
<td> Phone number </td>
</tr>
<% do, not customerlist.eof%>
Detect if the record is the last one. EOF represents end of File.
<TR>
<td><% =customerlist ("customer number")%></td>
<td><% =customerlist ("Company name")%></td>
<td><% =customerlist ("Contact person name")%></td>
<td><% =customerlist ("City")%></td>
<td><% =customerlist ("phone number")%></td>
</TR>
<% =customerlist ("customer number")%> can be said to be a shorthand for the Response.Write method. Writes the data in the customer Number field to the TD tab.
<% Customerlist.movenext
Loop
%>
If you have not yet arrived at the last one, the pointer moves to the next one. With Do While ... Loop loops to get all of the records individually.
</TABLE>
</CENTER>
<center>
<input type= "button" value= "Add Data" >
</center>
</BODY>
</HTML>
Flaw: Only the most basic functions are realized. Do not say other functions, only on the data to add and view the function, more perfect should also add "paging function." Otherwise, it is basically impossible to show all the data to a certain extent.
This period is complete.