国
国色天香
Unregistered / Unconfirmed
GUEST, unregistred user!
我是用下面的函数压缩的:
function CompactDatabase(AFileName,APassWord:string):boolean;
//压缩与修复数据库,覆盖源文件
Const
SConnectionString= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;'+'Jet OLEDBatabase Password=%s;';
var
STempFileName:string;
vJE:OleVariant;
begin
STempFileName:=GetTempPathFileName;
try
vJE:=CreateOleObject('JRO.JetEngine');
w_data.ADOC1.Close;
vJE.CompactDatabase(format(SConnectionString,[AFileName,APassWord]),
format(SConnectionString,[STempFileName,APassWord]));
result:=CopyFile(pchar(STempFileName),PChar(AFileName),false);
DeleteFile(pchar(STempFileName));
except
result:=false;
end;
end;
有时候是正常的,有时候压缩后就打不开了,总提示某某表没有打开权限,压缩后出错的情况最近出现好几次.
怎样解决?
function CompactDatabase(AFileName,APassWord:string):boolean;
//压缩与修复数据库,覆盖源文件
Const
SConnectionString= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;'+'Jet OLEDBatabase Password=%s;';
var
STempFileName:string;
vJE:OleVariant;
begin
STempFileName:=GetTempPathFileName;
try
vJE:=CreateOleObject('JRO.JetEngine');
w_data.ADOC1.Close;
vJE.CompactDatabase(format(SConnectionString,[AFileName,APassWord]),
format(SConnectionString,[STempFileName,APassWord]));
result:=CopyFile(pchar(STempFileName),PChar(AFileName),false);
DeleteFile(pchar(STempFileName));
except
result:=false;
end;
end;
有时候是正常的,有时候压缩后就打不开了,总提示某某表没有打开权限,压缩后出错的情况最近出现好几次.
怎样解决?