我有一个Midas项目,该项目在服务器的RemoteDataModules之一中使用TDataSetProvider
目前,我正在使用以下事件
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;
可以看到,在finally块中调用了DoAfterApplyUpdates。这意味着它总是被称为任何异常。
关于delphi - 在Delphi中有关TDataSetProvider的信息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/421934/