W
wangchengwu
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟刚写了一个数据恢复功能,但不能处理异常,如:目标数据库和源数据库目标的表不相同时,怎样给出个提示,不许恢复!!!!
代码如下:
uses shellapi;
procedure TForm1.Button1Click(Sender: TObject);
var
sSourceFileDirNameExt : String;
sDestFileDirNameExt : String;
begin
with opendialog1 do
begin
title:='数据恢复';
AdoTable1.Close;
ADOConnection1.Close;
if Execute then
begin
try
sSourceFileDirNameExt:=opendialog1.FileName;
sDestFileDirNameExt:=ExtractFilePath(Application.exename)+'/YGXX.mdb';
copyfile(pchar(sSourceFileDirNameExt),pchar(sDestFileDirNameExt),false);
ADOConnection1.Open;
adotable1.TableName := 'jtzjcy';
adotable1.Open;
except
MessageBox(Handle,'打开数据库失败,请检查数据库是损坏.','内行系统信息',MB_OK+MB_ICONERROR);
Exit;
end;
end;
end;
end;
代码如下:
uses shellapi;
procedure TForm1.Button1Click(Sender: TObject);
var
sSourceFileDirNameExt : String;
sDestFileDirNameExt : String;
begin
with opendialog1 do
begin
title:='数据恢复';
AdoTable1.Close;
ADOConnection1.Close;
if Execute then
begin
try
sSourceFileDirNameExt:=opendialog1.FileName;
sDestFileDirNameExt:=ExtractFilePath(Application.exename)+'/YGXX.mdb';
copyfile(pchar(sSourceFileDirNameExt),pchar(sDestFileDirNameExt),false);
ADOConnection1.Open;
adotable1.TableName := 'jtzjcy';
adotable1.Open;
except
MessageBox(Handle,'打开数据库失败,请检查数据库是损坏.','内行系统信息',MB_OK+MB_ICONERROR);
Exit;
end;
end;
end;
end;