Get table Data and Column Headers From A Table
Enter The Table Name:
Enter The DSN:

Here is the code that does all the work. <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit '---------------------- WEB SITE: ----------------------- ' File Name: DynamicTableResults.asp ' ' Purpose: This will take a table name from DynamicTable.asp ' (you must specify the DSN also) ' and list all the data and table column names. ' Good to see what's in a table when you forgot or don't know. 'Dim and Construct the SQL Query notice the request.form entry 'To get a table name entered by the user Dim strSQL strSQL = "SELECT * FROM " & Request.Form("Table") & "" 'This will display the SQL string on the page, 'i use it to check for errors Response.Write strSQL 'Dim and create a connection object, notice the request.form to get 'a DSN entered by the user in the objConn.Open line. You must have 'a DSN created for the database on your machine and know it's name. Dim objConn Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open "DSN=" & Request.Form("DSN") & "" 'Dim and create a recordset object Dim objRS Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open strSQL, objConn Dim fCount, i fCount = objRS.Fields.Count - 1 Response.Write "" for i=0 to fCount Response.Write "" next Response.Write "" While Not objRS.EOF Response.Write "" for i=0 to fCount Response.Write "" next Response.Write "" objRS.MoveNext Wend Response.Write "
" & objRS(i).name & "
 " & objRS(i).value & "
" 'Close and dereference objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing '----- ' Begin HTML output %> Untitled <% '---------------------------------------------------------------------- ' End HTML Output '---------------------------------------------------------------------- '---------------------------------------------------------------------- ' All ASP post processing code goes here, as well as ' sub routines and functions '---------------------------------------------------------------------- %>