views:

293

answers:

1

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 possible 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: 

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;
Francis Lee
With your approach I will only commit when the option or application closes
Jlouro
ok do it in the afterpost event
Francis Lee