用压缩数据 库来实现数据库备份
function daocompactdb(srcfile,password:string):boolean; //compactdatabase
var
dstfile:widestring;
db:_DBEngine;
dtbs:dao97.database;
begin
dstfile:=extractfilepath(application.ExeName)+'tempfile.mdb';
try
try
db:=coDBEngine.Create;
dtbs:=db.OpenDatabase(srcfile,true,false,';pwd='+password);
dtbs.NewPassword(password,'');
dtbs.Close;
db.CompactDatabase(srcfile,dstfile,emptyparam,emptyparam,'');
if not copyfile(pchar(dstfile),pchar(srcfile),false) then
begin
deletefile(dstfile);
result:=false;
exit;
end;
finally
dtbs:=db.OpenDatabase(srcfile,true,false,';pwd=');
dtbs.NewPassword('',password);
dtbs.Close;
end;
result:=true;
except // wrap up
result:=false;
end; // try/except
deletefile(dstfile);
end;