Open Directory Site ADO Tutorials

ASP | XML | VBScript | JavaScript | ADO | CSS | XMLDOM | PHP | Operating Systems

Home >> ADO >> ADO Display

ADO Display

 

The most common way to display data from a recordset, is to display the data in an html table.

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>

Cheap Web Hosting Articles - Web Site Design & Web Hosting Tutorials - Domain Hosting