K
kitewgd
Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下程序修复ACCESS数据库:
function GetTempPathFileName(): String;
var
SPath,SFile:array [0..254] of char;
begin
GetTempPath(254,SPath);
GetTempFileName(SPath,'~CP',0,SFile);
Result := SFile;
DeleteFile(PChar(Result));
end;
function CompactDatabase(AFileName,APassWord:string): Boolean;
var
vJE: OleVariant;
STempFileName: String;
begin
STempFileName := GetTempPathFileName;
try
vJE := CreateOleObject('JRO.JetEngine');
vJE.CompactDatabase(Format(SConnectionString,[AFileName,APassWord]),
Format(SConnectionString,[STempFileName,APassWord]));
Result := CopyFile(PChar(STempFileName),PChar(AFileName),false);
DeleteFile(STempFileName);
except
Result := False;
end;
end;
调用:
if CompactDatabase('D:/test.mdb','password') then
ShowMessage('Repair Successfull!');
当执行如上程序时出现了如下错误,不知为何,请各位大虾指教,谢谢了!
ERROR: 不可识别的数据库格式:/test.mdb.
function GetTempPathFileName(): String;
var
SPath,SFile:array [0..254] of char;
begin
GetTempPath(254,SPath);
GetTempFileName(SPath,'~CP',0,SFile);
Result := SFile;
DeleteFile(PChar(Result));
end;
function CompactDatabase(AFileName,APassWord:string): Boolean;
var
vJE: OleVariant;
STempFileName: String;
begin
STempFileName := GetTempPathFileName;
try
vJE := CreateOleObject('JRO.JetEngine');
vJE.CompactDatabase(Format(SConnectionString,[AFileName,APassWord]),
Format(SConnectionString,[STempFileName,APassWord]));
Result := CopyFile(PChar(STempFileName),PChar(AFileName),false);
DeleteFile(STempFileName);
except
Result := False;
end;
end;
调用:
if CompactDatabase('D:/test.mdb','password') then
ShowMessage('Repair Successfull!');
当执行如上程序时出现了如下错误,不知为何,请各位大虾指教,谢谢了!
ERROR: 不可识别的数据库格式:/test.mdb.