LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

ASP在线压缩ACCESS数据库

admin
2010年7月8日 13:53 本文热度 5492
使用access作数据库的站长会发现,随着时间的增长你的数据库会越来越大,甚至你删除数据数据库不会变小还会变大,其实在access数据库里还有好几个隐藏表!有次一个人让我给他看看网站,网站占用空间500多m,他压缩后发给我后是50m,但当我给压缩数据库后发现,他的网站总占用空间不到10m...几十倍的差距。用下面的代码可以实现对access数据库的压缩,不会损伤数据库的任何数据,可安全使用 [br]<% [br]path=server.mappath("mydb.mdb") [br]is97=true '这个参数决定调用方法的参数不同,若是97数据库请设为true,否则为false [br]response.write pa_compactdb(request.querystring("path"), is97) [br][br][br]function pa_compactdb(m_strdbfile, m_bisaccess97) [br] dim objfso, ofileb,ofilea,objengine, strdbfileb,jet_3x,sizestring [br] dim bhaserror [br] on error resume next [br] bhaserror = false [br] strdbfilea = server.mappath(m_strdbfile) [br] strdbfileb = left(strdbfilea,instrrev(strdbfilea,"\")) [br] set objfso = createobject("scripting.filesystemobject") [br][br] if objfso.fileexists(strdbfilea) then [br] set objengine = createobject("jro.jetengine") [br][br] if err.number<>0 then [br] pa_compactdb = "error:" & err.description [br] err.clear [br] else [br] set ofileb=objfso.getfile(strdbfilea) [br] sizestring="before compacted,filesize is "&(ofileb.size/1024)&"kb;
" [br] if m_bisaccess97 = true then [br] objengine.compactdatabase "provider=microsoft.jet.oledb.4.0;data source=" & strdbfilea, _ [br] "provider=microsoft.jet.oledb.4.0;data source=" & strdbfileb & "_temp.mdb;" _ [br] & "jet oledb:objengine type=" & jet_3x [br] else [br] objengine.compactdatabase "provider=microsoft.jet.oledb.4.0;data source=" & strdbfilea, _ [br] "provider=microsoft.jet.oledb.4.0;data source=" & strdbfileb & "_temp.mdb" [br] end if [br][br] objfso.copyfile strdbfileb & "_temp.mdb",strdbfilea [br] objfso.deletefile(strdbfileb & "_temp.mdb") [br] set objengine = nothing [br] set ofilea=objfso.getfile(strdbfilea) [br] sizestring=sizestring&"after compacted,filesize is "&(ofilea.size/1024)&"kb!
" [br] pa_compactdb ="your database(" & strdbfilea & ") has benn compacted successfully!
"&sizestring [br] end if [br] else [br] pa_compactdb = "your database path is wrong!" [br] end if [br] set objfso = nothing [br] set ofileb = nothing [br] set ofilea = nothing [br] on error goto 0 [br]end function [br]%>

该文章在 2010/7/8 13:53:02 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved