access用数据库压强方法,用代码实现:
'压强代码:
if request("compress")="压 缩" then
dbpath=server.mappath("../"&request("dbpath"))
if dbpath<>"" and fso.fileexists(server.mappath("../"&request("dbpath"))) then
set fs=fso.getfile(server.mappath("../"&request("dbpath")))
ofsize=fs.size '原数据库大小
set fs=nothing
strdbpath=left(dbpath,instrrev(dbpath,"\"))
set engine=createobject("jro.jetengine")
engine.compactdatabase "provider=microsoft.jet.oledb.4.0;data source="&dbpath, _
"provider=microsoft.jet.oledb.4.0;data source="&strdbpath&"temp.mdb"
fso.copyfile strdbpath&"temp.mdb",dbpath
fso.deleteFile strdbpath&"temp.mdb"
set fs=fso.getfile(server.mappath("../"&request("dbpath")))
nfsize=fs.size '压缩后的大小
set fs=nothing
set engine=nothing
cflag="true" '压缩成功标识
else
cflag="false" '压缩失败标识
end if
end if