学习坊广告 网站建设咨询电话0711-5903333 、 QQ:215665888        将学习坊设为主页     广告赞助QQ:410899793     主页申请

在线压缩Access数据库

来源:网络 【www.cn0711.net】   作者:未知【学习坊转】 [字体: ]
While working on BuildDB/Buildapp online Demo, I developed a lITtle function that will compact Access databases over the web. Here's a "no-frills" page that'll compact the databases for you.

One problem wITh Access databases is that "holes" are created when records are deleted, making the database fluffy and bloated. Compacting the database makes IT lean and efficient again.

Note: This function/page can easily be combined wITh the Buildapp front end file navigation and search pages (Installment II), to create an application that'll make IT easy to handle this formerly troublesome chore for all the databases on your machine/web sITe..

++++++++++++ Begin Compact.asp +++++++++++++++++++++++++++++
<%
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 = "Your database, " & dbpath & ", has been Compacted" & vbCrLf
Else
CompactDB = "The database name or path has not been found. Try Again" & vbCrLf
End If

End Function
%>
<html><head><tITle>Compact Database</tITle></head><body>

<h2 align="center"> Compacting an Access database</h2>
<p align="center">
<form action=compact.asp>
Enter relative path to the database, including database name.<br><br>
<input type="text" name="dbpath"><br><br>
<input type="checkbox" name="boolIs97" value="True"> Check if Access 97 database
<br><i> (default is 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
%>
</p></body></html>

++++++++++++ End Code




 

录入:学习坊

查看对 在线压缩Access数据库 的评论 【 发表见解 】 【 查看见解 】 【 打印资料 】  
上一篇:ASP备份数据库 
下一篇:巧用FileSystem组件实现WEB应用中的本地特定打印
百度中>“在线压缩Access数据库”相关内容 google中>“在线压缩Access数据库”相关内容
雅虎中>“在线压缩Access数据库”相关内容 搜狗中>“在线压缩Access数据库”相关内容
中搜中>“在线压缩Access数据库”相关内容 爱问中>“在线压缩Access数据库”相关内容