我有点石成金的项目使用的一个TDataSetProvider的RemoteDataModules在服务器

目前,我使用的下列事件

  • BeforeApplyUpdates-创建一个对象
  • BeforeUpdateRecord-使用的对象
  • AfterApplyUpdates到毁灭的对象

问题:

将'AfterApplyUpdates'总是被称为即使是一个更新的错误?

有帮助吗?

解决方案

如果你看看源代码:

function TCustomProvider.DoApplyUpdates(const Delta: OleVariant; MaxErrors: Integer;
  out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant;
begin
  SetActiveUpdateException(nil);
  try
    try
      if Assigned(FOnValidate) then
        FOnValidate(Delta);
      DoBeforeApplyUpdates(OwnerData);
      Self.OwnerData := OwnerData;
      try
        Result := InternalApplyUpdates(Delta, MaxErrors, ErrorCount);
      finally
        OwnerData := Self.OwnerData;
        Self.OwnerData := unassigned;
      end;
    except
      on E: Exception do
      begin
        SetActiveUpdateException(E);
        raise;
      end;
    end;
  finally
    try
      DoAfterApplyUpdates(OwnerData);
    finally
      SetActiveUpdateException(nil);
    end;
  end;
end;

同比增长看到,DoAfterApplyUpdates是所谓在最后块。这意味着它是总是叫不管任何例外。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top