首先在中間層定義三個方法.
procedure TWzef.wz_begin
trans(out _result: WideString);
begin
if not WzConnection.InTransaction then
WzConnection.begin
Trans;
_result:='開始異動交易.';
end;
procedure TWzef.wz_committrans(out _result: WideString);
begin
WzConnection.CommitTrans;
_result:='存檔成功,已經向數据庫提交.';
end;
procedure TWzef.wz_rollbacktrans(out _result: WideString);
begin
WzConnection.RollbackTrans;
_result:='存檔失敗,事務已經回混.';
end;
然后客戶端在更新數据時先調用中間層的方法.