Subject Re: [IBO] onpreparesql & odd behaviour
Author Heri
Hi Pete

Nice to hear that you have found a workaround (isolating FQueryList as
global variable).

This is what I assumed. I never used this RTTI methods. But what I can see:
there is nowhere a reference to self (datamodule) when calling
SetMethodProp. When executing comes into QueryOnPrepareSql the FQueryList
cannot be referenced because there is no reference to the class (remember:
every Method of a class has as hidden first parameter a reference to self;
callbacks like DelphiEvents must supply this reference explicitely).

What happens if you supply
M.Data := self
after M.Code := MethodAddress(...)
?

But it should be much more easier, since you have already checked if the
component is a TIBODataSet:

if(Components[I] is TIBODataSet) then
TIBODataset(Components[I]).OnPrepareSQL := QueryOnPrepareSql;

Heri




----- Original Message -----
From: "petegajria" <petegajria@...>
To: <IBObjects@yahoogroups.com>
Sent: Thursday, June 27, 2002 8:37 PM
Subject: Re: [IBO] onpreparesql & odd behaviour


> heres the relevant code fragments
>
> FQueryList is declared in the classes protected section
>
> //datamodule.create
> var
> I : Integer;
> M : TMethod;
> begin
>
> FQueryList := TStringList.Create;
>
> for I:=0 to ComponentCount -1 do
> begin
> if(Components[I] is TIBODataSet)then
> begin
> if IsPublishedProp(Components[I], 'OnPrepareSql') then
> begin
> M.Code := MethodAddress('QueryOnPrepareSql');
> if Assigned(M.Code) then
> SetMethodProp(Components[I], 'OnPrepareSql', M );
> end; // OnPrepareSql
>
>
> & heres the onpreparesql
> procedure TDataSetDM.QueryOnPrepareSql(Sender : TObject);
> begin
> TIBOQuery(Sender).SQLWhereItems.AddStrings(FQueryList);
> FQueryList.Clear;
> end;
>
> no rocket science here.....
> ive checked & the querylist is being created before
> the onprepare ever fires
>
> again help would be greatly appreciated
>
> regards
> pete
>
> --- In IBObjects@y..., Bender Heri <heribender@w...> wrote:
> > > the events for all tiboq on a datamodule are being assigned at
> runtime
> > > via method pointers & rtti
> > >
> > Can you show this code? I assume this is the culprit.
> >
> > Heri
>
>
>
>
___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
> without the need for BDE, ODBC or any other layer.
>
___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info
papers,
> keyword-searchable FAQ, community code contributions and more !
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>