Code for ASP to obtain the name and structure of an ACCESS database table
Last Update:2018-12-08
Source: Internet
Author: User
<Html>
<Head>
<Title> obtain ACCESS database table name_www.jb51.net </title>
</Head>
<Body style = "text-align: left; margin-left: 50px; font-family: 'arial'; font-size: 12px">
<Form style = "padding: 5px; margin: 5px; margin-left: 0px" name = "get" action = "" method = "post">
Database path: <input type = "text" name = "path" value = "" size = "50"/>
<Input type = "hidden" name = "ari" value = "1"/>
<Input type = "submit" value = "View"/>
</Form>
<Hr>
<%
If request. form ("ari") = "1" and request. form ("path") <> "then
Dim conn, connstr, I, SQL, rs
On error resume next
Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ =" + server. mappath (request. form ("path "))
Set Conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open connstr
If Err Then
Err. Clear
Set Conn = Nothing
Response. Write "database connection error. Check the connection string. "
Response. End
End If
%>
<Font color = red> <% = conn. connectionstring %> </font> <%
J = 0
Dim tablecount
Tablecount = 0
Set shm = conn. OpenSchema (20)
Shm. MoveFirst
Do While Not shm. EOF
If shm ("TABLE_TYPE") = "TABLE" Then
If Left (shm ("table_name"), 1) <> "~ "Then': filter out the hidden table here.
J = j + 1
Call GetFileds (shm ("table_name "))
End If
End If
Shm. MoveNext
Loop
Response. write "Total" & j & "data tables! "
Else
Response. write "End if
%>
</Body>
</Html>
<%
Function GetFileds (TableName)
Set rs = server. createobject ("adodb. recordset ")
Dim SQL
SQL = "select * from" & TableName
Rs. Open SQL, conn, 1, 1
Dim Cont
Cont = rs. Fields. Count
Response. write "<div style =" "margin-bottom: 10px; padding: 5px; border: 1px # dddddd solid; background: # eeeeee" ">" & vbcrlf
Response. write "Table <font color = red> <B>" & TableName & "</B> </font> contains" & Cont & "fields, as follows: <br> "& vbcrlf
For I = 0 To Cont-1
Dim filtype
Select case rs. fields (I). type
Case 3
Filtype = "automatic number (number )"
Case 1, 202
Filtype = "character"
Case 1, 203
Filtype = "Remarks"
Case 1, 125
Filtype = "date"
Case 11
Filtype = "True/false (yes/no )"
End select
Response. write "<font color = red>" & I & "</font> -- <font color = green> <B>" & rs. fields (I ). name & "</B> </font> --" & filtype & "; <br/>" & vbcrlf
Next
Response. write "</div>" & vbcrlf
Rs. Close
Set rs = nothing
End Function
%>