用ACCESS數(shù)據(jù)庫(kù)開(kāi)發(fā)的網(wǎng)站,當(dāng)隨著網(wǎng)站數(shù)據(jù)量的不斷增長(zhǎng).數(shù)據(jù)庫(kù)的容量也是不斷加大.這讓ASP程序速度直線下降.如果才能讓ACCESS數(shù)據(jù)庫(kù)容量盡可能小.我們要對(duì)它進(jìn)行壓縮處理.
下面是我整理后的源代碼,復(fù)制另存為compact.asp并上傳到數(shù)據(jù)庫(kù)所在目錄即可正常使用。
以下為引用的內(nèi)容:
<html>
<head>
<title>ACCESS數(shù)據(jù)庫(kù)壓縮程序-網(wǎng)頁(yè)制作教程</title>
</head>
<body bgcolor="e0f8ef">
<div>
<div align="center"><font color="#3300FF">
<b><font size="5">通用ACCESS數(shù)據(jù)庫(kù)在線壓縮程序</font></b></font><br>
</div>
<div>
<br>
|
本程序其實(shí)是通過(guò)FSO權(quán)限和JET引擎連接,
因此在使用之前請(qǐng)確認(rèn)你的服務(wù)器支持FSO
(filesystemobject)權(quán)限并安裝的ACCESS最新驅(qū)動(dòng)!
從安全出發(fā),請(qǐng)?jiān)趬嚎s之前備份原始數(shù)據(jù)庫(kù)!
以下為引用的內(nèi)容:
</div><br>
<div align="center">運(yùn)行環(huán)境:在WIN98SE+PWS、WIN2000+IIS5.0 <br>
<%
Const JET_3X = 4
Function CompactDB(dbPath, boolIs97)
Dim fso, Engine, strDBPath
strDBPath = left(dbPath,instrrev(DBPath,""))
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then
Set Engine = CreateObject("JRO.JetEngine")
If boolIs97 = "True" Then
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb;" _
& "Jet OLEDB:Engine Type=" & JET_3X
Else
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath, _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb"
End If
fso.CopyFile strDBPath & "temp.mdb",dbpath
fso.DeleteFile(strDBPath & "temp.mdb")
Set fso = nothing
Set Engine = nothing
CompactDB = "你的數(shù)據(jù)庫(kù), " & dbpath & ", 已經(jīng)被壓縮" & vbCrLf
Else
CompactDB = "你輸入的數(shù)據(jù)庫(kù)路徑或名稱(chēng)未找到,請(qǐng)重試" & vbCrLf
End If
End Function
%>
</div>
</div>
<form name="compact" method="post" action="compact.asp">
<div align="center">
<font size="2"><b><font color="#FF0000">
壓縮選項(xiàng),請(qǐng)仔細(xì)填寫(xiě)!</font></b><br>
<br>
|
輸入數(shù)據(jù)庫(kù)全稱(chēng):
以下為引用的內(nèi)容:
<input type="text" name="dbpath">
(包括擴(kuò)展名,如MDB、ASA、ASP等)<br>
<br>
<input type="checkbox" name="boolIs97" value="True">
檢查是否為ACCESS97數(shù)據(jù)庫(kù)<br>
(默認(rèn)為ACCESS2000的數(shù)據(jù)庫(kù))<br>
<br>
<input type="submit" name="submit" value="確認(rèn)壓縮">
</font></div>
</form>
<div align="center"><font size="2">
<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")
If dbparesponse.write(CompactDB(dbpath,boolIs97))
End If
%>
<br>
</font></div></body></html>th <> "" Then
dbpath = server.mappath(dbpath)
|
注意:由于本例實(shí)用的是FSO操作ACCESS文件,所以要使用本例請(qǐng)確保你的服務(wù)器支持FSO支持.