From: zdtips@zdtips.com

Sent: Tuesday, January 25, 2000 12:06 PM
To: asptips@zdtips.com
Subject: Active Server Developer Tips, 01/26/2000

A quick way to read database contents in ASP

Often, as you develop a complex Web application, you may find that
keeping track of the vast quantities of data on multiple domains
in databases that change daily quickly becomes a daunting task.
To provide a quick, easy way to view a table's contents during
development, try this script on for size:

<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim objConn, objRec, strTable, strCmd
strTable = Request("tbl")
strCmd = "SELECT * FROM " & strTable

Set objConn=Server.CreateObject("ADODB.Connection")
Set objCmd = Server.CreateObject("ADODB.Command")
set objRec = Server.CreateObject("ADODB.Recordset")

objConn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
Server.MapPath("Biblio.mdb")
objRec.open strCmd, objConn, , 1, 1

sTable="<TABLE BORDER='1'><THREAD><TR>"
'Collect the Field Names
For Each objFld in objRec.Fields
sTable = sTable & "<TD>" & objFld.Name & "</TD>"
Next

'Build the table body
sTable = sTable & "</TR></THREAD>" & "<TBODY><TR><TD>" _
& objRec.getString(, ,"</TD><TD>", "</TD></TR><TR><TD>") _
& "</TD></TR></TBODY></TABLE>"
Response.write sTable

objRec.Close
Set objRec = Nothing
objConn.Close
Set objConn = Nothing
%>

Place the script in an HTML page, and save it as TableMe.asp.
Then, pass the table name you want to display in the URL, as in:

www.thesite.com/location/TableMe.asp?tbl=Authors

Notice how the ADO getString() function uses HTML table tags as
delimiters and so formats the entire data set in one big chunk.
Talk about speed!

Submitted by: Greg Sawin, MorePhotos.com