Delphi中TDataSetProvider所需的信息

Cha*_*iga 2 delphi delphi-2006

我有Midas项目,在服务器的RemoteDataModules之一中使用TDataSetProvider

目前我正在利用以下事件

  • BeforeApplyUpdates - 创建一个Object
  • BeforeUpdateRecord - 使用该对象
  • AfterApplyUpdates - 来破坏对象

题:

即使是更新错误,也会始终调用'AfterApplyUpdates'吗?

Too*_*the 11

如果你看一下源代码:

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;
Run Code Online (Sandbox Code Playgroud)

Yoy看到在finally块中调用了DoAfterApplyUpdates.这意味着它总是被称为任何例外的问题.