function daocompactdb:boolean; //compactdatabase
var
srcfile,dstfile:widestring;
db:_DBEngine;
dtbs:database;
begin
srcfile:=extractfilepath(application.ExeName)+'agritax.mdb';
dstfile:=extractfilepath(application.ExeName)+'tempfile.mdb';
try
try
db:=coDBEngine.Create;
dtbs:=db.OpenDatabase(srcfile,true,false,';pwd=agriculture');
dtbs.NewPassword('agriculture','');
dtbs.Close;
dtmd.DataModule1.adocntion.Connected:=false;
db.CompactDatabase(srcfile,dstfile,emptyparam,emptyparam,'');
// db.CompactDatabase(srcfile,dstfile,emptyparam,emptyparam,'agriculture');
dtmd.DataModule1.adocntion.Connected:=false;
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('','agriculture');
dtbs.Close;
dtmd.DataModule1.adocntion.Connected:=true;
end;
//dtmd.DataModule1.adocntion.Connected:=true;
result:=true;
except // wrap up
dtmd.DataModule1.adocntion.Connected:=true;
result:=false;
dtmd.DataModule1.adocntion.Connected:=true;
end; // try/except
deletefile(dstfile);
dtmd.DataModule1.adocntion.Connected:=true;
end;
function daorepairdb:boolean; //repairdatabase
var
db:_DBEngine;
begin
db:=coDBEngine.Create;
try
db.RepairDatabase(extractfilepath(application.ExeName)+'agritax.mdb');
result:=true;
except
result:=false;
end;
end;