function TDataSet.ApplyUpdates(MaxErrors: Integer): Integer;
var
S: string;
E: Exception;
begin
CheckBrowseMode;
// 注意:这里用的是 ChangeCount 不是 UpdatesPending。
if ChangeCount = 0 then
Result := 0
else
if Connection.Transaction.Active and not Connection.Transaction.Immediate then
begin
if FUpdating then raise Exception.Create('正在提交');
FUpdating := True;
DoApplyUpdates(Delta, MaxErrors, Result);
end
else
begin
Reconcile(DoApplyUpdates(Delta, MaxErrors, Result));
if FReconcileError <> '' then
begin
S := FReconcileError;
FReconcileError := '';
E := Exception.Create('提交数据失败:' + S);
TransactionCommitError(Connection.Transaction, E, nil);
raise E;
end;
end;
end; |