您好,欢迎访问一九零五行业门户网

纯编码如何实现Access数据库的建立或压缩(4)

set ca = nothing createdbfile = true end if end function public function compactdatabase(byval dbfilename,byval dbver,byval savepath) 压缩 数据库 文件 0 为access 97 1 为access 2000 on error resume next if right(savepath,1) or right(savepat
 set ca = nothingcreatedbfile = true
end if
end function
public function compactdatabase(byval dbfilename,byval dbver,byval savepath)
’压缩数据库文件
’0 为access 97
’1 为access 2000
on error resume next
if right(savepath,1) or right(savepath,1)/ then savepath = trim(savepath) &
if left(dbfilename,1)= or left(dbfilename,1)=/ then dbfilename = trim(mid(dbfilename,2,len(dbfilename)))
if dbexists(savepath & dbfilename) then
response.write (对不起,该数据库已经存在!)
compactdatabase = false
else
dim cd
set cd =server.createobject(jro.jetengine)
if err.number0 then
response.write (无法压缩,请检查错误信息
& err.number &
& err.description)
err.clear
exit function
end if
if dbver=0 then
call cd.compactdatabase(provider=microsoft.jet.oledb.3.51;data source= & savepath & dbfilename,provider=microsoft.jet.oledb.3.51;data
source= & savepath & dbfilename & .bak.mdb;jet oledb;encrypt database=true)
else
call cd.compactdatabase(provider=microsoft.jet.oledb.4.0;data source= &
savepath & dbfilename,provider=microsoft.jet.oledb.4.0;data source= &
savepath & dbfilename & .bak.mdb;jet oledb;encrypt database=true)
end if
’删除旧的数据库文件
call deletefile(savepath & dbfilename)
’将压缩后的数据库文件还原
call renamefile(savepath & dbfilename & .bak.mdb,savepath & dbfilename)
set cd = false
compactdatabase = true
end if
其它类似信息

推荐信息