欢迎光临
我们一直在努力

在线压缩Access数据库

建站超值云服务器,限时71元/月

while working on builddb/buildapp online demo, i developed a little function that will compact access databases over the web. heres a "no-frills" page thatll 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 thatll 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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在线压缩Access数据库
分享到: 更多 (0)

相关推荐

  • 暂无文章