Subject Re: [IBO] Questions about Using IB_Transaction
Author Svein Erling Tysvær
I don't know the IBO internals, but I would be slightly surprised if your
code would have worked. You do assign an already started transaction to
your dataset. What happens if you change your sample to:

Var
Con1 : TIB_Connection;
Con2 : TIB_Connection;
Dts1 : TIB_Dataset;
Dts2 : TIB_Dataset;
Tr1 : TIB_Transaction;`
begin
...
Dts1.Ib_Connection := Con1;
dts1.Ib_Transaction := Tr1;
dts2.ib_Connection := Con2; //Moved up a few lines
Dts2.ib_Transaction := Tr1; //Moved up a few lines
Dts1.SQL.Text := 'select * from table1';
Dts1.Open; //This line will start your transaction.
Showmessage(Dts1.FieldByname('Field1').asString);
Dts1.close;

Dts2.Sql.text := 'update Table1 set field1="123abc";';
Dts2.Open;
Dts2.Close;

Tr1.Commit;
end;

Do you still get the error?
Set

At 10:29 04.12.2000 -0500, you wrote:
>Hi,
> I want to execute many different SQL statement within the same
>Transaction and be able to rollback everything or commit everything..
>The First Statements works fine, but the second I get an Error "Invalid
>Transaction Handle (expecting explicit Transaction start)".
>Is it wrong to use the same transaction for to separate connection to the
>same database?
>Is there some other way to achieve this?
>
>example :
> Var
> Con1 : TIB_Connection;
> Con2 : TIB_Connection;
> Dts1 : TIB_Dataset;
> Dts2 : TIB_Dataset;
> Tr1 : TIB_Transaction;`
> begin
> ...
> Dts1.Ib_Connection := Con1;
> dts1.Ib_Transaction := Tr1;
> Dts1.SQL.Text := 'select * from table1';
> Dts1.Open;
> Showmessage(Dts1.FieldByname('Field1').asString);
> Dts1.close;
>
> dts2.ib_Connection := Con2;
> Dts2.ib_Transaction := Tr1;
> Dts2.Sql.text := 'update Table1 set field1="123abc";';
> Dts2.Open; <-- I get the error here.
> Dts2.Close;
>
> Tr1.Commit;
> end;
>
>Any help would be greatly appreciated!
>Thanks
>
>Joël Gauvreau.
>Programmer - UQAT
>
>
>[Non-text portions of this message have been removed]
>
>
>
>
>
>