This is actually very easy, except possibly the dropdown list part. Anyone else know how to populate the dropdown list with every table name in a db?
the rest of it looks like this:
- dim conn, rs, query, x
-
-
query = "SELECT * FROM " & request("tableDropDown")
-
'get every field from the table specified in the dropdown
-
-
set conn = server.createObject("adodb.connection")
-
conn.open "myDSN1" 'this should be your system DSN for this db, or if you
-
'don't use a DSN, you can modify this line to include the path to the db file
-
-
set rs = server.createObject("adodb.recordet")
-
rs.open query, conn
-
'populates the recordset "rs" from the data specified in "query" using the
-
' connection specified in "conn"
-
-
'make a header row in the table
-
response.write "<table><tr>"
-
for each x in rs.fields
-
response.write "<th>" & x.name & "</th>" & vbNewLine
-
next
-
response.write "</tr>"
-
-
'the body of the table is the actual data
-
do until rs.eof 'keep going until we get to the end of the recordset
-
response.write "<tr>" 'each record makes up one table row
-
for each x in rs.fields
-
response.write "<td>" & x.value & "</td>" & vbNewLine
-
'the value in each field makes up the values in each cell of the table
-
next
-
response.write "</tr>"
-
rs.movenext 'go to the next record
-
loop
-
response.write "</table>"
Normally I try not to give whole code answers since it is important for the askers to work out how to solve problems, but this was an approach that really changed my perspective and simplified how I displayed tables. Does everything make sense?
Jared