How to compact/repair a database!!!

Results 1 to 2 of 2

Thread: How to compact/repair a database!!!

  1. #1
    Access Database Guest

    Default How to compact/repair a database!!!

    I did a *lot* of digging in MSDN and the Access Help, and found some interesting ways to use DAO in ASP, mainly to compact and repair databases. Here&#039s what I finally came up with:<BR>--BEGIN--<BR>&#060;%<BR>sub CompactDB(database) &#039Leave off .mdb<BR>dim DaoDB,Fs<BR>set fs=server.createobject("scripting.filesystemobject ")<BR>if fs.fileexists(server.mappath("..database\" & database & "_optimized.mdb")) then<BR> fs.deletefile server.mappath("..database\" & database & "_optimized.mdb")<BR>end if<BR>set daodb=server.createobject("dao.dbengine.36")<BR>da odb.compactdatabase server.mappath("..database\" & database & ".mdb"),server.mappath("..database\" & database & "_optimized.mdb")<BR>&#039Replace old db with new db<BR>fs.copyfile server.mappath("..database\" & database & "_optimized.mdb"),server.mappath("..database\" & database & ".mdb"),true<BR>fs.deletefile server.mappath("..database\" & database & "_optimized.mdb")<BR>&#039Database UPDATED!!!<BR>end sub<BR><BR>sub RepairDB(database) &#039Leave off .mdb<BR>dim DaoDB<BR>set daodb=server.createobject("dao.dbengine.35")<BR>da odb.repairdatabase server.mappath("..database\" & database & ".mdb")<BR>&#039Database REPAIRED!!!<BR>end sub<BR>%&#062;<BR>--END--<BR>Notice that in compact, I used version 3.6, but when I used 3.6 to repair, it couldn&#039t find the repairdatabase method. By simply using 3.5 instead, the problem was solved. Anyone know of a better way to do this? Any explanations why 3.6 wouldn&#039t repair?

  2. #2
    Gianfri Guest

    Default RE: How to compact/repair a database!!!

    Thanks for the idea, when I try it on my personal IIS it works, but when I try it on my Hosted Web Server it returns an error at this point:<BR><BR>set daodb=server.createobject("dao.dbengine.36")<BR><B R>Here is the error:<BR><BR>Server object error &#039ASP 0177 : 80040112&#039 <BR><BR>Server.CreateObject Failed <BR><BR><BR>Is there somebody who can explain me???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts