Subject RE: [IBO] Statement must have an IB_Connection assigned
Author Alan McDonald
> I have seen some other similar questions but have not been able to
> resolve this issue:
>
> Everything worked fine till I upgraded to IBO 4.7. The DB is (FB2.0).
> now I get this error and cant seem to track it down:
> "Statement must have an IB_Connection assigned: <no name
>
> BackGround:
> I have create a class for some Temporay Queries..
> "uses
> classes,IBODataset, DB, csintf;
>
> type
> TPKIBQuery = class(TIBOQuery)"
>
> then create an SQL state as follows:
> lQryMisc := TPKIBQuery.Create(nil);
> lQryMisc.SQL.Clear;
> lQryMisc.SQL.Add('Select a.* from AGENCY_USER a ');
> lQryMisc.SQL.Add('Where a.LOGIN_NAME =:LOGIN_NAME');
> lQryMisc.Prepare;
> lQryMisc.Params.ParamValues['LOGIN_NAME'] := aUser;
> lQryMisc.Open;"
>
> Each time I get the prepare statment i get the following error:
> "Statement must have an IB_Connection assigned: <no name>"

if you say this worked prior to upgrade (i.e. it worked even though you were
not assigning an IB_Connection explicitly). Then I would assume it has
something to do with creation order. If the IB_Session and IB_Connection
were created before your query, then it may have previously adopted the
default (previously created) IB_Connection.
FWIW, I would always assign an IB_Connection to the query (and perhaps a
transaction) explicitly and not rely on default assignments.
Alan