最清晰的做法:
首先,在服务器端接口上定义三个方法(不需要参数):
begin
Trans
CommitTrans
RollBackTrans
三个方法的实现内容为:
begin
Trans:
Adoconnection1.begin
Trans;
CommitTrans:
AdoConnection1.CommitTrans;
RollBackTrans:
AdoConnection1.RollBackTrans;
客户端可以这样调用:
SocketConnection1.AppServer.begin
Trans;
try
if (ClientDataset1.ApplyUpdates(0)=0) and (ClientDataset2.ApplyUpdates(0)=0) then
SocketConnection1.AppServer.CommitTrans
else
SocketConnection1.AppServer.RollBackTrans;
Except
On E:Exceptiondo
begin
showmessage('更新时发生如下错误:'+e.message);
SocketConnection1.AppServer.RollBackTrans;
end;
end;