这是在 20CN网络安全小组第一代论坛 的论坛 网站建设 中的主题 Access数据库整理


要查看这个主题,请使用这个 URL:
http://www.20cn.net/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic;f=4;t=000235

leaflet (编号: 2423) 发表于 :
 
请问在运行IIS的NT服务器上使用Access数据库时,由于增加删除记录导致数据库文件增大后,能否在服务器端通过ASP使用SQL语句达到整理数据库的目的,而不将数据库下载压缩后再上传。
 
小强 (编号: 858) 发表于 :
 
下面是我写的一段程序,如果你有更高的见解请与我联系。
<%
option explicit
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 = "你的数据库: " & dbpath & ", 压缩成功!" & vbCrLf
Else
CompactDB = "数据库文件名或路径不正确,压缩失败!" & vbCrLf
End If

End Function
%>
<html><head><title>压缩数据库</title></head><body>

<h2 align="center"> ACCESS数据库压缩</h2>
<p align="center">
<form action=compact.asp>
请输入数据库绝对路径及数据库文件名<br>
<input type="text" name="dbpath"><br><br>
<input type="checkbox" name="boolIs97" value="True"> 选择数据库类型为 Access 97
格式
<br><i>(默认是 Access 2000 格式)</i><br><br>
<input type="submit">
<form>
<br><br>
<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")

If dbpath <> "" Then
dbpath = server.mappath(dbpath)
response.write(CompactDB(dbpath,boolIs97))
End If
%>
</form>
</body></html>
 






Powered by Infopop Corporation
UBB.classic™ 6.5.0
NetDemon修改版 1.5.0, 20CN网络安全小组 版权所有。