用Delphi 压缩Access数据库

uses dao97,dao2000;

procedure CompactMdbDatabase(srcDbname,dstDbname,oldpwd,newpwd:string;bAccess97:boolean=true);
var idbEngine:_dbEngine;
begin
  if oldpwd <>'' then oldpwd := ';pwd='+oldpwd;
  if newpwd <>'' then newpwd := ';pwd='+newpwd;

  if bAccess97 then
  begin
    idbengine := CreateComObject(dao97.CLASS_DBEngine) as _DBEngine;
    idbEngine.CompactDatabase(srcDbname,dstDbname,newpwd,dbVersion30,oldpwd);
  end else
  begin
    idbengine := CreateComObject(dao2000.CLASS_DBEngine) as _DBEngine;
    idbEngine.CompactDatabase(srcDbname,dstDbname,newpwd,dbVersion40,oldpwd);
  end;
end;

posted @ 2007-03-28 15:06  斌哥  阅读(508)  评论(0编辑  收藏  举报