Question about Access database performance/compact

Results 1 to 2 of 2

Thread: Question about Access database performance/compact

  1. #1
    Join Date
    Dec 1969

    Default Question about Access database performance/compact

    When the db on my server is updated and modified the size of it of course increases, I wonder if this is important for the performance of the db, or if compacting it will increase the performance. Anyway, is there a way to compact the db remotely.<BR><BR><BR>Thanx in advance.<BR><BR>Espen

  2. #2
    Thomas Täfvander Guest

    Default RE: Question about Access database performance/com

    Yep! the performance is affected!<BR><BR>Here´s some code that You can run from ASP!<BR><BR><BR>If Request("Action")="Compress" Then<BR> Conn.Close &#039 closing the databaseopening cause it can´t be busy! (if it´s not opened yet remark this line)<BR> Dir = Request.ServerVariables("SCRIPT_NAME")<BR> Dir = StrReverse(Dir)<BR> Dir = Mid(Dir, InStr(1, Dir, "/"))<BR> Dir = StrReverse(Dir)<BR> Path = Server.MapPath(Dir) & "\" <BR> If Right(Path,20) = "wwwrootapps2proof\" Then &#039Suggesting that the database is above the root in a folder named database and the script is in folder appsproof!<BR> Path = Left(Path, Len(Path) -20)<BR> Path = Path & "database\"<BR> End If<BR> Set Engine = CreateObject("DAO.DBEngine.35") &#039Creating objekt for compressing <BR> Set Fs=Server.Createobject("scripting.filesystemobject ") &#039Creating objekt to be able to delete and change name <BR> <BR> If Fs.Fileexists (Path & "Ao_Proof_optimized.mdb") Then<BR> &#039Deleting the old optimized databas if you done this before and didn&#039t clean up after You!<BR> Fs.Deletefile (Path & "Ao_Proof_optimized.mdb")<BR> End if<BR> <BR> &#039Creating a new optimized database with the same name as the original+ _optimized!&#039<BR> Engine.CompactDatabase Path & "Ao_Proof.mdb", Path & "Ao_Proof_optimized.mdb"<BR> <BR> &#039Reparing the new database if something went wrong!<BR> Engine.RepairDatabase Path & "Ao_Proof.mdb" <BR> <BR> &#039Replacing the old db with the new one!<BR> Fs.copyfile (Path & "Ao_Proof_optimized.mdb"),(Path & "Ao_Proof.mdb"),true<BR> <BR> &#039Deling the temporarily created database!<BR> Fs.Deletefile (Path & "Ao_Proof_optimized.mdb")<BR> <BR> &#039Database updated!<BR>End If<BR><BR>Best //

Posting Permissions

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