开发者

How can I do multi Transaction in DBExpress

I am using DBExpress with blackfish.

How can I do multi Transaction?

I have several GRIDs all in editing at once and all will have to be saved at once. The begin editing and post are to be determined by the end user, as he works, and in different place of the application, so difficult to do in one only transaction.

UPDATE:

OK the problem is that to application works in concurrency and I have to commit new data as soon as possibl开发者_高级运维e so that other user can have access to it.

So the grids info as to be committed shortly after the post, or with the post.


A transaction works 'perse' over various datasets. If you are working with dbexpress it's even better. Simply, let your enduser do all the edit, delete & posts needed over the various grid and when you need to save his work make something like :

var
 mytransaction : TDBXTransaction;
begin
   mytransaction := sqlconnection1.BeginTransaction;
   try
      if clientdataset1.ChangeCount > 0 then clientdataset1.ApplyUpdates(0);
      ...
      if clientdatasetn.ChangeCount > 0 then clientdatasetn.ApplyUpdates(0);
      sqlconnection1.CommitFreeAndNil(mytransaction);
   except
     sqlconnection1.RollbackFreeAndNil(mytransaction);
   end;
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜