Re: Code to Compact/Repair Access 2003 database
- From: MikeR <nf4lNoSpam@xxxxxxxxx>
- Date: Tue, 29 Aug 2006 06:54:04 -0400
TMA wrote:
Can anyone put some code here that would use that function in access to COMPACT/REPAIR the database?This works for Access 2000. Watch line wrap.
Import the JRO_TLB.pas from msjro.dll.
Mike
procedure TfrmLog.mnuCompactDBClick(Sender: TObject);
var
wholePath, SProvider1: string;
JE: TJetEngine;
begin
SProvider1 = 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=';
wholePath := AppDir + '\' + DBName;
if FileExists(AppDir + '\compacted.mdb') then
DeleteFile(AppDir + '\compacted.mdb');
if FileExists(wholePath) then
begin
JE:= TJetEngine.Create(Application);
try
try
JE.CompactDatabase(SProvider1 + wholePath, SProvider1 + AppDir + '\compacted.mdb');
except
on E:Exception do
ShowMessage(E.Message);
end;
finally
JE.FreeOnRelease;
if FileExists(AppDir + '\compacted.mdb') then
begin
DeleteFile(wholepath);
RenameFile(AppDir + '\compacted.mdb', wholepath);
end;
end;
end;
.
- References:
- Prev by Date: Re: Code to Compact/Repair Access 2003 database
- Next by Date: Re: TDBmemo fields and Memory Tables
- Previous by thread: Re: Code to Compact/Repair Access 2003 database
- Index(es):