对于客户端的AstaClientSocket:
1.StartTransaction 启动事务
2.EndTransaction(Commit: Boolean)
Commit为True时为提交,False时为回滚.
(其实这只是给服务器的参数,具体动作还是要到服务器上去做)
-------------------------------------
事实上这样的调用也只是触发应用服务器上的AstaServerSocket上的两个事件,
你当然要在这两个事件上写相应的代码。
OnTransactionBegin事件:
procedure TfrmMain.AstaServerSocket1TransactionBegin(Sender: TObject;
ClientSocket: TCustomWinSocket; Session: TComponent;
TransActionName: string);
begin
try
with Session as TDataBase do begin
if not IsSQLBased then TransIsolation := tiDirtyRead;
if not InTransaction then StartTransaction;
end;
LogIt('Start Transaction ' + TransactionName);
except
LogException(ClientSocket, Exception(exceptObject).Message, True);
end;
end;
---------------------
OnTransactionEnd事件:
procedure TfrmMain.AstaServerSocket1TransactionEnd(Sender: TObject;
ClientSocket: TCustomWinSocket; Session: TComponent; Success: Boolean);
begin
try
with Session as TDataBase do
if Success then begin
Commit;
LogIt('Transaction Commited');
end else begin
RollBack;
LogIt('Transaction Rolled Back');
end;
except
LogException(ClientSocket, Exception(exceptObject).Message, True);
end;
end;
上面是ASTA事务的基本原理,对于你问题我不知道是不是这个意思:
在客户端的AstaClientSocket中写下面的代码:
AstaClientSocket1.StartTransaction //启动
try
你的操作1;
....操作2;
AstaClientSocket1.EndTransaction(True);//提交
except
AstaClientSocket1.EndTransaction(False); //回滚
end;
这样不就行了...:》