Compress a access database using ADO 
Author Message
 Compress a access database using ADO

How do i compress a access database using ADO,
A smal example, or a few lines of code would be very appreciated.

Thanks to all



Tue, 17 Aug 2004 16:34:32 GMT  
 Compress a access database using ADO



Quote:
> How do i compress a access database using ADO,
> A smal example, or a few lines of code would be very appreciated.

procedure Access_Compact(const aAccess: string);
const
  bak_ext           = '.$$$';
  stAccessDB        = 'Provider=Microsoft.Jet.OLEDB.4.0;'+
                      'Data Source=%s';
var
  JetEngine         : Variant;
  TempName          : string;
begin
  TempName := ChangeFileExt(aAccess, bak_ext);
  DeleteFile(TempName);
  JetEngine := CreateOleObject('JRO.JetEngine');
  try
    JetEngine.CompactDatabase(
      Format(stAccessDB, [aAccess]),
      Format(stAccessDB, [TempName]));
    DeleteFile(aAccess);
    RenameFile(TempName, aAccess);
  finally
    JetEngine := Unassigned;
  end;
end;

greetings
Andreas

--
Database Explorer for ADO (Freeware)
http://www.tobilan.de/adodeskexe.zip



Tue, 17 Aug 2004 18:34:04 GMT  
 Compress a access database using ADO
Thanks for your reply, it works.



Quote:



> > How do i compress a access database using ADO,
> > A smal example, or a few lines of code would be very appreciated.

> procedure Access_Compact(const aAccess: string);
> const
>   bak_ext           = '.$$$';
>   stAccessDB        = 'Provider=Microsoft.Jet.OLEDB.4.0;'+
>                       'Data Source=%s';
> var
>   JetEngine         : Variant;
>   TempName          : string;
> begin
>   TempName := ChangeFileExt(aAccess, bak_ext);
>   DeleteFile(TempName);
>   JetEngine := CreateOleObject('JRO.JetEngine');
>   try
>     JetEngine.CompactDatabase(
>       Format(stAccessDB, [aAccess]),
>       Format(stAccessDB, [TempName]));
>     DeleteFile(aAccess);
>     RenameFile(TempName, aAccess);
>   finally
>     JetEngine := Unassigned;
>   end;
> end;

> greetings
> Andreas

> --
> Database Explorer for ADO (Freeware)
> http://www.tobilan.de/adodeskexe.zip



Tue, 17 Aug 2004 19:00:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using ADO with Encrypted/Password Protected Access databases

2. Compact Access Database using ADO

3. compress Access databases

4. Creating an MS Access DB using ADO Express/Delphi 5

5. New record using ADO link and AutoNumber in Access

6. Record locking with ADO Express, ADO 2.5 and Access 2000 .mdb files

7. Compressing MS access db

8. Access compress

9. ACCESS compress

10. Compressed R/O Database

11. Compressing a database

12. Compressed Database

 

 
Powered by phpBB® Forum Software