procedure TDM.CompactAndRepairDataBase; var JetEng: Variant; Src, Dst: WideString; SrcMDB, DstMDB: String; Provider: String; begin DM.ConnectionScholl.Close; JetEng := CreateOleObject('JRO.JetEngine'); try Provider := 'Provider=Microsoft.Jet.OLEDB.4.0;'; SrcMDB := GetPathApp + 'Schollc.dat'; DstMDB := GetPathApp + 'Scholl.dat'; Src := Provider + 'Data Source=' + SrcMDB; Dst := Provider + 'Data Source=' + DstMDB; if RenameFile(DstMDB, SrcMDB) then begin JetEng.CompactDatabase(Src, Dst); DeleteFile(PChar(SrcMDB)); end; finally JetEng := Unassigned; end; end;