李维的【Delphi5.X ADO_MTS_COM+高级程序设计】书中第二章第4节中有:
procedure TForm1.ADODataSet1BeforePost(DataSet: TDataSet);
begin
ADOConnection1.begin
Trans ;
end ;
procedure TForm1.ADODataSet1AfterPost(DataSet: TDataSet);
begin
ADOConnection1.CommitTrans;
end;
procedure TForm1.ADODataSet1PostError(DataSet: TDataSet;
E:
EDatabaseError;v a r Action: TDataAction);
begin
ADOConnection1.RollbackTrans;
Action := daAbort;
end;
procedure TForm1.ADODataSet1BeforePost(DataSet: TDataSet);
begin
ADOConnection1.begin
Trans ;
end ;
procedure TForm1.ADODataSet1AfterPost(DataSet: TDataSet);
begin
ADOConnection1.CommitTrans;
end;
procedure TForm1.ADODataSet1PostError(DataSet: TDataSet;
E:
EDatabaseError;v a r Action: TDataAction);
begin
ADOConnection1.RollbackTrans;
Action := daAbort;
end;
-----------------------
agree
你也可以在中间层自定三个方法,客户端需要处理事务时调用。。。。。