How ASP Gets the field descriptions for an Access database

Source: Internet
Author: User

How the ASP Gets the field description code for the Access database is as follows:


<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> extract descriptive information for an access field </title>

<%
Dim table
Table = Trim (Request ("T1"))
Database=trim (Request ("D1"))
%>
<body>
<form method= "POST" action= "" >
Data file name: <input type= "text" name= "D1" size= "" Value=<%response.write (Database)%> > name of data file in same directory such as:database.mdb<br>
Table...... Name: <input type= "text" name= "T1" size= "" value=<%response.write (table)%> >database.mdb table name <br>
<input type= "Submit" value= "submitted" name= "B1" ><input type= "reset" value= "reset" name= "B2" >
</form>

<%
If table = "" Then
Response.Write ("Post Nothing")
else%><%
Dim conn
Dim connstr
On Error Resume Next
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" +server.mappath (database) + ";"
Set Conn=server.createobject ("ADODB. CONNECTION ")
Conn.Open ConnStr
Response.Write (connstr+ "<br>")
Dim sql
Dim rs
Sql= "SELECT * from" +table+ ""
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,conn,3,2
Response.Write (sql+ "<br>")

If Rs. State = adStateOpen Then
Cnnstate = "Open"
Else
Cnnstate = "Closed"
End If
Response.Write (cnnstate + "<br>")
Response.Write ("Number of columns:" +cstr (Rs.fields.count) + "<br>")

For I=0 to Rs.fields.count-1
Response.Write "<TH>" + RS (i). Name + "</TH>;<br>"
Next


Dim Mytablename
Dim Myfieldname

Dim MyDB
Set Mydb=server.createobject ("Adox.catalog")
Dim MyTable
Set Mytable=server.createobject ("Adox.table")
Dim MyField
Set MyField =server.createobject ("Adox.column")
Dim Pro

On Error Resume Next

Mydb.activeconnection =conn


For each MyTable in Mydb.tables
For each MyField in Mytable.columns
' Response.Write ' FieldName: "& FieldType (Myfield.type) &" FieldSize: "& Myfield.definedsize ' FieldType (Pro. Type)
' Response.Write table & '. "& Myfield.name &": "' Oh here's the change, the previous mistake
Response.Write Mytable.name & "." & Myfield.name & ":" ' Oh, there's a change here, wrong before.
For all Pro in Myfield.properties
If Pro.name= "Description" and pro. Value <> "" Then Response.Write Pro. Value & "<br>" "Mytable.name &": "& Myfield.name &": "& Pro." Name & ":" & Pro. Value
Next
Next
Next

Rs.close ()
Conn.close ()
End If
%>

</body>



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.