|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
procedure Tform1.UpData(Sign:Smallint;Sql: array of String; cds: array of TClientDataSet;
var ReSign: Smallint; var ErrStr: String);
var
iMaxErrors,iErrorCount,i:Integer;
begin
try
try
ADOConnection1.BeginTrans;
iMaxErrors:=0;
iErrorCount:=-1;
ReSign:=1;
for i:=0 to Length(Sql)-1 do
begin
if cds[i].ChangeCount>0 then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(Sql[i]);
ADOQuery1.Open;
DataSetProvider1.ApplyUpdates(cds[i].Delta,iMaxErrors,iErrorCount);
if iErrorCount>0 then
begin
ReSign:=-1;
ErrStr:='UIErrStr';
exit;
end;
end;
end;
except
on E:Exception do
begin
ReSign:=-1;
ErrStr:=E.Message;
if Sign=0 then
messagebox(Application.Handle,PChar(ErrStr),'提示',mb_ok+MB_ICONINFORMATION);
end;
end;
finally
if ReSign<>1 then
begin
ReSign:=-1;
ErrStr:='UIErrStr';
ADOConnection1.RollbackTrans;
if Sign=0 then
messagebox(Application.Handle,PChar(ErrStr),'提示',mb_ok+MB_ICONINFORMATION);
end
else
begin
ReSign:=1;
ADOConnection1.CommitTrans;
end;
end;
end;
新手请教!for循环里面不懂 |
|