<%
'#########################
'作用:压缩access数据库(默认是ac2000)
'日期:2004-12-10
'最后修改:2005-9-16
'#########################
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><br>
<input type="text" name="dbpath"><br><br>
<input type="checkbox" name="boolIs97" value="True">如果是ac97,请选上钩
<br><i> (默认是ac2000)</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
%>
</p>
</body>
</html>
asp在线压缩access数据库
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]
相关文章:
- 一句代码得到表中的某行的指定字段(2007-9-17 2:30:24)
- 数据库设计技巧(2007-9-3 2:32:32)
- ACCESS中使用SQL语句几点技巧(2007-8-15 6:19:58)
- Access命令行参数(2007-8-8 10:15:16)
- VB访问Access数据库(2007-7-4 9:40:50)
- Access2003开发者扩展工具集概述(2007-5-18 5:33:7)
- asp中使用access的系统表的方法(2007-5-10 4:29:56)
- Access2000数据库80万记录通用快速分页类(2007-5-1 1:9:19)
- 防止Access密码被破译(2007-3-9 10:15:42)
- Access 数据库表规格(2007-1-5 5:37:9)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
