Sent: Tuesday, January 25, 2000 12:06 PM
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:

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") strCmd, objConn, , 1, 1

'Collect the Field Names
For Each objFld in objRec.Fields
sTable = sTable & "<TD>" & objFld.Name & "</TD>"

'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

Set objRec = Nothing
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:

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,