ASP get Access database table name and structure code _ Application Tips

Source: Internet
Author: User
Tags access database

<title> Get Access database table name _www.jb51.net</title>
<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= "/>"
<input type= "hidden" name= "Ari" value= "1"/>
<input type= "Submit" value= "View"/>
</form>
<%
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);D bq=" +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, please 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 as not SHM. Eof
If SHM ("table_type") = "TABLE" Then
If Left (SHM ("table_name"), 1) <> "~" Then ' here filter out hidden tables
J=j+1
Call Getfileds (SHM ("table_name"))
End If
End If
Shm. MoveNext
Loop
Response.Write "A total of" &j& "data Table!"
Else
Response.Write "End If
%>
</body>
<%
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 "<font color=red><b>" &TableName& "</b></font> contains" &Cont& " fields, specifically as follows:<br> "&vbcrlf
For i = 0 to Cont-1
Dim filtype
Select Case Rs.fields (i). Type
Case 3
Filtype= "Automatic numbering (number)"
Case 202
Filtype= "character"
Case 203
Filtype= "Remarks"
Case 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
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.