<title>提取access字段的说明">

asp如何获取access数据库的字段说明

80酷酷网    80kuku.com

  

asp如何获取access数据库的字段说明代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>提取access字段的说明信息</title>
</head>
<%
dim table                  
table = trim(request("t1"))
database=trim(request("d1"))
%>
<body>
<form method="POST" action="">
    数据文件名:<input type="text" name="D1" size="40" value=<%response.write(database)%> >同目录下数据文件名称 如:database.mdb

    表......名:<input type="text" name="T1" size="40" value=<%response.write(table)%> >database.mdb中的表名

    <input type="submit" value="提交" name="B1"><input type="reset" value="重置" 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+"
")
        dim sql
        dim rs
         sql="select * from "+table+""
        set rs=server.createobject("adodb.recordset")
        rs.open sql,conn,3,2
        response.write(sql+"
")
        
        If rs.State = adStateOpen Then
            cnnState = "open"
        Else
            cnnState = "closed"
        End If
        response.write(cnnState +"
")
        response.write("列数:"+cstr(rs.fields.count)+"
")
        
        For i=0 to rs.fields.count-1
            Response.Write "<TH>"+ rs(i).Name +"</TH>;
"
        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 &":" '呵呵这里有变动,以前的有误
            response.write MyTable.name & "." & MyField.name &":" '呵呵这里有变动,以前的有误
            For Each pro In MyField.Properties
                if pro.name="Description" and pro.Value <> "" then    response.write  pro.Value & "
" 'MyTable.Name & " : " & MyField.Name & " : " & pro.Name & " : " & pro.Value
            Next
        Next
    Next

        rs.close()
        conn.close()
   end if
%>

</body>

</html>

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: