Subject RE: [IBO] error "Transaction is not valid for the current connection"
Author Support List
Falko,

> with IBO 4.6 the following code snippet runs without error.
> On IBO 4.9 (latest build) it runs into error!?!?!
>
> procedure TForm1.btnTAProblemClick(Sender: TObject);
> var
> qr : TIB_cursor;
> cn : TIB_Connection;
> ta : TIB_transaction;
> begin
> cn := nil;
> qr := nil;
> try
> ta := TIB_Transaction.Create(Self);
> ta.starttransaction;
> cn := TIB_Connection.create( self);
> cn.defaulttransaction := ta;
> cn.Username := 'SYSDBA';
> cn.password := 'masterkey';
> cn.protocol := cpTCP_IP;
> cn.database := eDatabase.text;
> cn.connected := true;
>
> qr := TIB_cursor.create( self);
> qr.IB_Connection := cn;
> qr.sql.text := 'select * from rdb$database';
> qr.prepare;
>
> qr.open; // with IBO 4.6 ok.
> // with IBO 4.9 error with message "Transaction is not
> // valid for the current connection"
> except
> on e:Exception do
> Showmessage(e.message);
> end;
> qr.close;
> cn.close;
> ta.rollback;
> qr.free;
> cn.free;
> ta.free;
> end;
>
> Is this a known incompatibility between IBO 4.6 and 4.9?
> Is it a bug?
> Or did I missed something?

This is a result of fixing a bug in IBO. You need to add in the lines of
code to explicitly assign the transaction's IB_Connection and the cursor's
IB_Transaction property.

Jason LeRoy Wharton
www.ibobjects.com