FireDAC.Phys.MSAcc.TFDMSAccessService.Compact
Delphi
procedure Compact;
C++
void __fastcall Compact();
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | FireDAC.Phys.MSAcc.pas FireDAC.Phys.MSAcc.hpp |
FireDAC.Phys.MSAcc | TFDMSAccessService |
Description
Compacts an Access database.
Use the Compact method to compact a database. To run Compact, an application must specify:
- Database--the source database file name.
- DestDatabase--the destination database file name. If it is not specified, then DestDatabase is equal to Database.
Optionally, Encrypted, Password, and SortOrder can be specified.
The file pointed by Database must be a valid .MDB file. DestDatabase can point to the same file as Database, in which case the file will be compacted into the same location.
If DestDatabase names a different file than Database, the file named as the DestDatabase will be deleted when Compact is called. If the operation fails, an EMSAccessNativeException exception is raised.
Example 1
// Compact non-secured database FDMSAccessService1.Database := 'c:\test.mdb'; FDMSAccessService1.DestDatabase := 'c:\test2.mdb'; FDMSAccessService1.Compact;
Example 2
// Compact secured database FDMSAccessService1.Database := 'c:\test.mdb'; FDMSAccessService1.Password := 'J@^^1234pw'; FDMSAccessService1.Compact;
Example 3
// Reset password of secured database FDMSAccessService1.Database := 'c:\test.mdb'; FDMSAccessService1.Password := 'J@^^1234pw'; FDMSAccessService1.ResetPassword := True; FDMSAccessService1.Compact;