How to list the table names and field names in the database in an ASP

Source: Internet
Author: User
Tags dsn table name
Program | data | Database <%
DSN = "Dsn=dsnname"
Const adSchemaTables = 20
adSchemaColumns = 4
Set oconn = Server.CreateObject ("ADODB. Connection ")

oConn.Open DSN
Set Rstschema = Oconn.openschema (adSchemaColumns)
Response.Write "<table>"
Response.Write "<tr><td>table Name</td><td>field Name</td><td>field type</ Td><td>is Nullable</td><td>field size</td></tr> "
Tablename= ""
Do Until rstschema.eof
Response.Write "<tr><td>"
If Rstschema ("table_name") <> TableName Then
Response.Write Rstschema ("table_name")
TableName = Rstschema ("table_name")
Else
Response.Write ""
End If
Response.Write "</td><td>" & Rstschema ("column_name") & "</td><td>"
Select Case Rstschema ("Data_type")
Case "130"
If Rstschema ("character_maximum_length") = 1073741823 Then
Response.Write "Memo"
Else
Response.Write "Text"
End If
Case 135
Response.Write "Date/time"
Case 3
Response.Write "Long Integer"
Case 11
Response.Write "Yes/no"
Case 131
Response.Write "Currency"
Case Else
Response.Write Rstschema ("Data_type")
End Select
Response.Write "</td><td>" & Rstschema ("Is_nullable") & "</td><td>"
If Rstschema ("Character_maximum_length") <> 1073741823 Then
Response.Write Rstschema ("Character_maximum_length")
Else
Response.Write ""
End If
Response.Write "</td></tr>"
Rstschema.movenext
Loop
Response.Write "</table>"
%>



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.