Today came up with the idea of using ASP to get all the table names in the database, the field names of all the tables, and the contents of all the fields in the database only if you know the names of the databases. After a period of time to query information and changes, and finally made out, now share with you.
<%
' function: Display the table name, field name, field contents in the database
' Original: Wangsdong
' Source: www.111cn.net
' original article, reprint please keep this information, thank you
% >
Just change the database name and run the program, and you'll see the results.
Set Rs=server. CreateObject ("Adodb.recordset")
db= "Db1.mdb"
Set Conn=server. CreateObject ("Adodb.connection")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB)
Conn.Open ConnStr
Set Rs=conn.openschema (20)
Do Until Rs. Eof
If RS (3) = "TABLE" Then
Response.Write "Table name:" &rs (2) & "
"
Set Rs1=server. CreateObject ("Adodb.recordset")
Sql= "SELECT * from" &rs (2)
Set rs1=conn.execute (SQL)
Response.Write "Field Name:"
For I=0 to Rs1.fields.count-1
Response.Write Rs1.fields (i) .name& ""
Next
Response.Write "
"
Do as not rs1.eof
Response.Write ""
For I=0 to Rs1.fields.count-1
T=rs1.fields (i). Name
Response.Write Rs1 (t) & ""
Next
Response.Write "
"
Rs1.movenext
Loop
Response.Write "
"
End If
Rs. MoveNext
Loop
Set rs=nothing
Set conn=nothing