ASP獲取ACCESS數(shù)據(jù)庫表名及結(jié)構(gòu)的代碼
更新時(shí)間:2008年08月20日 01:01:50 作者:
此方法可獲得ACCESS數(shù)據(jù)的表名及其結(jié)構(gòu),數(shù)據(jù)類型等...
程序過濾了幾個(gè)ACCESS數(shù)據(jù)庫的幾個(gè)隱藏表(可能是導(dǎo)致ACCESS數(shù)據(jù)庫刪除數(shù)據(jù)還會變大的原因)
<html>
<head>
<title>獲取ACCESS數(shù)據(jù)庫表名_www.dbjr.com.cn</title>
</head>
<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">
數(shù)據(jù)庫路徑:<input type="text" name="path" value="" size="50" />
<input type="hidden" name="ari" value="1" />
<input type="submit" value="查看" />
</form>
<hr>
<%
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);DBQ="+server.mappath(request.form("path"))
Set Conn=Server.CreateObject("ADODB.Connection")
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "數(shù)據(jù)庫連接出錯(cuò),請檢查連接字串。"
Response.End
End If
%>
<font color=red><%=conn.connectionstring%></font><hr>
<%
j=0
dim tablecount
tablecount=0
Set shm = conn.OpenSchema(20)
shm.MoveFirst
Do While Not shm.EOF
If shm("TABLE_TYPE") = "TABLE" Then
If Left(shm("table_name"), 1) <> "~" Then '這里過濾掉隱藏表
j=j+1
call GetFileds(shm("table_name"))
End If
End If
shm.MoveNext
Loop
response.write "共有 "&j&" 個(gè)數(shù)據(jù)表!"
else
response.write "<h3>請輸入數(shù)據(jù)庫相對路徑查看具體內(nèi)容!</h3>"
end if
%>
</body>
</html>
<%
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> 中含有"&Cont&"個(gè)字段,具體如下:<br>"&vbcrlf
For i = 0 To Cont - 1
dim filtype
select case rs.fields(i).type
case 3
filtype="自動編號(數(shù)字)"
case 202
filtype="字符"
case 203
filtype="備注"
case 125
filtype="日期"
case 11
filtype="真/假(是/否)"
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
%>
相關(guān)文章
ASP基礎(chǔ)入門第四篇(腳本變量、函數(shù)、過程和條件語句)
大家在學(xué)習(xí)了腳本語言 VBScript 的變量、常量和過程的基本概念后,本期將繼續(xù)向各位介紹 VBScript 的函數(shù)和語法。2015-10-10ASP向Excel導(dǎo)數(shù)據(jù)(圖片)終結(jié)版 ASP操作Excel
ASP向Excel導(dǎo)數(shù)據(jù)(圖片)終結(jié)版 ASP操作Excel,需要的朋友可以參考下。2009-11-11ASP 處理JSON數(shù)據(jù)的實(shí)現(xiàn)代碼
今天看網(wǎng)頁才發(fā)現(xiàn)了ASP也能處理JSON數(shù)據(jù)?呵呵,剛才論壇上看到一個(gè)兄弟寫的文章,沒有測試,不過理論上一定是可以的,之前腳本之家小編也發(fā)過類似的文章都可以看下2017-07-07用asp實(shí)現(xiàn)文件瀏覽、上傳、下載的程序
用asp實(shí)現(xiàn)文件瀏覽、上傳、下載的程序...2007-02-02用asp實(shí)現(xiàn)訪問遠(yuǎn)程計(jì)算機(jī)上MDB access數(shù)據(jù)庫文件的方法
用asp實(shí)現(xiàn)訪問遠(yuǎn)程計(jì)算機(jī)上MDB access數(shù)據(jù)庫文件的方法...2007-11-11asp下實(shí)現(xiàn)代碼的“運(yùn)行代碼”“復(fù)制代碼”“保存代碼”功能源碼
下面的代碼是通過字符替換的方法,不是正則表達(dá)式2008-12-12