数据库压缩

dim Engine,connpath,dbPath,strDBPath,fso
Set Engine = CreateObject("JRO.JetEngine") 

connpath="#jobs.asp"'与数据库在同一目录下,并没有临时文件temp.mdb
dbPath=server.MapPath(connpath)
strDBPath = left(DBPath,instrrev(DBPath,"\")) 
Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath, _ 
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb" 
Set Engine = nothing 

dbPath=server.MapPath(connpath)
strDBPath = left(DBPath,instrrev(DBPath,"\")) 

Set fso = CreateObject("Scripting.FileSystemObject") 
on error resume next
fso.CopyFile strDBPath & "temp.mdb",dbpath 
if err<>0 then coperr=true
fso.DeleteFile(strDBPath & "temp.mdb") 
if err<>0 then delerr=true
Set fso = nothing

posted @ 2016-07-20 12:25  码农耕耘  阅读(125)  评论(0编辑  收藏  举报