Subject Re: [IBO] How do I post multiple datasets in a single transaction?
Author masonwheeler
Umm... you lost me. What are you talking about here? I haven't begun the transaction yet; all I've done is edited the data in the dataset. And if that's what you mean, I can't set up the transaction first because there are multiple different editing operations which might require saving different groups of datasets together. Besides, if I did that, it would still require assigning a transaction to the dataset, and having to close and reopen the datasets every time I change transactions is insane. How do I fix that?

--- In IBObjects@yahoogroups.com, Marcin Bury <marcin.bury@...> wrote:
>
> Mason
>
> Why don't you assign transaction to datasets before starting
> transaction? Is there any particular reason that you assign transaction
> after it get started?
>
> Marcin
>
> W dniu 24.09.2012 23:20, masonwheeler pisze:
> > If I was using DBX, and I wanted to ensure that changes from multiple datasets were committed in a single transaction, it would go like this:
> >
> > tran := connection.BeginTransaction;
> > try
> > dataset1.ApplyUpdates;
> > dataset2.ApplyUpdates;
> > connection.CommitFreeAndNil(tran);
> > except
> > connection.RollbackFreeAndNil(tran);
> > end;
> >
> > IBO doesn't seem to work that way. And in fact, as I've just discovered, it doesn't seem to work *at all* when trying to post multiple datasets in one transaction.
> >
> > Here's what I'm trying, using datasets of type TIBOTable:
> >
> > tran := TIB_Transaction.Create(nil);
> > try
> > try
> > tran.IB_Connection := connection;
> > tran.StartTransaction;
> > dataset1.IB_Transaction := tran;
> > dataset2.IB_Transaction := tran;
> > dataset1.ApplyUpdates();
> > dataset2.ApplyUpdates();
> > tran.Commit;
> > except
> > tran.Rollback;
> > raise;
> > end;
> > finally
> > tran.Free;
> > end;
> >
> > The problem with this is that, for some bizarre reason, assigning the transaction object to the dataset SILENTLY CLOSES THE DATASET, which causes all the changes that I'm trying to commit to be lost!
> >
> > What in the world is going on here, and how do I get this to work properly?
> >
> >
> >
> > ------------------------------------
> >
>