1. ASP如何讀取ACCESS中欄位說明
1.asp如何獲取資料庫的欄位說明代碼如下:
<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<br>
表......名:<input type="text" name="T1" size="40" value=<%response.write(table)%> >database.mdb中的表名<br>
<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+"<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("列數:"+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 &":" '呵呵這里有變動,以前的有誤
response.write MyTable.name & "." & MyField.name &":" '呵呵這里有變動,以前的有誤
For Each 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>
</html>
2. 用ASP如何讀取ACCESS資料庫中的某個欄位[要代碼哦]
首先連接資料庫,然後:
<%
Set Rs = Server.CreateObject("ADODB.RecordSet") '創建一個對象
SQL = "Select 作者欄位名 From [表1]" '查詢表1中的作者欄位
Rs.Open SQL,Conn,1,1 '執行查詢
Do While Not Rs.Eof '開始循環顯示
Response.Write Rs("作者欄位名") '顯示查詢出的欄位名下的內容
Response.Write "<br>" '顯示一次輸出一個回車來換行(便於查看)
Rs.MoveNext '開始輸出下一條內容
Loop '結束循環
Set Rs = Nothing '關閉創建的對象
%>