' create the database connection
Set conn = Server.CreateObject("ADODB.Connection")
' open a connection to the Inventory database
conn.Open Application("DIAG_DB_CONN")
' get all of the records from the "Inventor"
table
strSQL = "SELECT * FROM " &
Application("DIAG_TABLE")
Set rs = conn.Execute(strSQL)
' call the function to show the recordset
as a table
DisplayResults(rs)
' close up the records set and database connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
'
' utility functions
'
Sub DisplayResults(rs)
' outputs a recordset as an HTML table
' parameters:
' rs (Recordset object): An open and already queried recordset to
display
' start the table
Response.Write("<table border=""1"">")
' write column names in the header
Response.Write("<tr>")
For i = 0 To (rs.Fields.Count - 1)
Response.write("<td><b>" & rs(i).Name
& "</b></td>" & vbCrLf)
Next
Response.Write("</tr>")
' loop through all the records and write
out each records as a row in the table
Do While Not(rs.EOF)
Response.Write("<tr>" & vbCrLf)
For i = 0 To (rs.Fields.Count - 1)
Response.Write("<td valign=""top"">")
If IsNull(rs(i).Value) Then
Response.Write("<NULL>")
Else
Response.Write(CStr(rs(i).Value))
End If
Response.Write("</td>" &
vbCrLf)
Next
Response.Write("</tr>" &
vbCrLf)
rs.MoveNext
Loop
Response.Write("</table>")
End Sub |