Please visit our sponsors !
ADO Display
The most common way to display data from a recordset, is to
display the data in an html table.
Examples
Display records
This example demonstrates how to first create a database connection, then create
a recordset, and
then display the data on an HTML page.
Display records in an HTML table
This example demonstrates how to display the data from the database table in an
HTML table.
Add headers to the table
This example demonstrates how to add headers to the HTML table to make it more
readable.
Display Records from a database
After a recordset is opened, we can display the data from the recordset on an
HTML page.
Suppose we have a database named "Northwind", we can display the
data from the "Customers" table with the following lines:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
rs.MoveNext
loop
rs.close
conn.close
%>
|
Display Records in a Table
We can also display the data from the "Customers" table inside an HTML
table with the following lines:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
%>
<table border="1" width="100%">
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
|
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|