软件教程

ASP压缩ACCESS数据库实用功能

来源: 本站    类别: 软件教程    日期: 2010/4/2

 

<%
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
%>
</div>
</div>
<form name="compact" method="post" action="compact.asp">
<div align="center">
<font size="2"><b><font color="#FF0000">
压缩选项,请仔细填写!</font></b><br>
<br>
输入数据库全称:
<input type="text" name="dbpath">
(包括扩展名,如MDB、ASA、ASP等)<br>
<br>
<input type="checkbox" name="boolIs97" value="True">
检查是否为ACCESS97数据库<br>
(默认为ACCESS2000的数据库)<br>
<br>
<input type="submit" name="submit" value="确认压缩">
</font></div>
</form>
<div align="center"><font size="2">
<%
Dim dbpath,boolIs97
dbpath = request("dbpath")
boolIs97 = request("boolIs97")

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


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com