- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi access 数据库压缩
//uses ComObj;
function compressDB(Afile:string):boolean;
//
var
DaoVar: OLEVariant;
begin
try
DaoVar := CreateOleObject('dao.DBEngine.36');
if FileExists('db.tmp') then deletefile('db.tmp');
// DaoVar.CompactDatabase(afile,'db.tmp'); //压缩无密码的数据库
//压缩有密码的数据库。注意:密码不能为空
DaoVar.CompactDatabase(afile,'db.tmp',';pwd='+SDefDataBasePwd+'',0,';pwd='+SDefDataBasePwd+'');
if deletefile(afile) then RenameFile('db.tmp',Afile);
result:=true;
except
result:=False;
end;
end;