咳,我现在这样做了,
COM内:
function TBusinessServer.SaveNodeInfo(var Data: OleVariant;
out ErrStr: WideString): HResult;
var
DeltaAgent: TDeltaAgent;
begin
Result := 0;
DeltaAgent := TDeltaAgent.Create(Self.FQuery,Data);
try
Self.FConnection.begin
Trans;
try
DeltaAgent.ModifyByDelta1('TBLUnitInfo',[usInserted,usModified,usDeleted]);
Self.FConnection.CommitTrans;
Result := 1;
except
on E:Exceptiondo
begin
Self.FConnection.RollbackTrans;
ErrStr := E.Message;
Result := 0;
end;
end;
finally
DeltaAgent.Free;
end;
end;
客户端调用:
procedure TdlgNodeInfo.acSaveExecute(Sender: TObject);
var
Data: OleVariant;
ICom: IBusinessServer;
ErrStr: WideString;
begin
if cdsNodeInfo.State<> dsBrowse then
cdsNodeInfo.Post;
if cdsNodeInfo.ChangeCount>0 then
begin
if ScanValidInfo=False then
Exit;
Data := cdsNodeInfo.Delta;
if not VarIsEmpty(Data) then
begin
ICom := dmBusinessData.GetIBusinessServer;
try
if ICom.SaveNodeInfo(Data,ErrStr)=0 then
raise Exception.Create(ErrStr);
finally
dmBusinessData.FreeIBusinessServer(ICOM);
end;
Application.MessageBox('已经保存','提示',MB_ICONINFORMATION);
acClose.Execute;
end;
end;
end;