Subject Re: [IBO] Invalid variant operation
Author Helen Borrie
At 09:46 AM 19/01/2004 +0000, you wrote:
> >
> > Yes, look at all your ParamByName, Params, FieldByName and Fields
> > references, where you use the ".Value" method and replace any
>problem ones
> > with ".AsWhatever", i.e. explicit casting.
>See I have just made a little test appl.
>In this I have only two TIBOQuerys.
>Then first does:
>Select * from Farver;
>The second does:
>Select * from Farver_Detail where Navn = :Navn;
>In my program is do this on FormShow:
> IBODatabase1.Open;
> IBOquery1.Open;
> IBOquery2.Open;
>When opening the second I get the above error.

Yes, of course. I hadn't even considered that you had unassigned
parameters. You're getting this invalid variant error because the
parameter is null (being unassigned.)

>If I instead does this on OnDataChange on the first TIBOQuerys
>datasource it works:
> IBOQuery2.Close;
> IBOQuery2.ParamByName('Navn').AsString := IBOQuery1.FieldByName
> IBOQuery2.OPen;

It should be in the BeforeOpen event of the query itself.

>Is this the way I should go, or can I do something to make IBO behave
>the same way as standard TQuery comp ?

AFAIK, that's how parameterised queries work in the VCL as well. You
always have to assign values to the parameters before opening the query.

If you want "master-detail" behaviour, you have to assign the detail's
Datasource property to the master query's datasource. Did you remember to
do that?

But, hint, if your detail's linking key has the same name as the master's
primary key, you don't have to worry about using the parameter at all -
leave it out - IBO takes care of that.

Of course you need correct KeyLinks in both sets, too.