Recent

Author Topic: TIBDynamicGrid - Query with where dows not display.  (Read 2126 times)

rvk

  • Hero Member
  • *****
  • Posts: 6640
Re: TIBDynamicGrid - Query with where dows not display.
« Reply #15 on: February 14, 2024, 04:43:00 pm »
yes, I have seen this, that I must put the Param BEFORE opening.
And sure I did.
Probably it would not even compile the other way round.
No no. You misunderstand. You need to put this in the OnBeforeOpen EVENT.
That's something different from "before opening".
The BeforeOpen event is executed automatically before Open.
And the TIBDynamicGrid does Close and Open itself.

So create the OnBeforeOpen event by doub;e clicking the event and put the ParamByName there.

As the DBGrid just as replacement works, - so the trouble shall be somewhere in the DBDynamicGrid.
The point is that TDBDynamicGrid changes the SQL statement and need to do a Close and Open for that Query.
And doing that will loose the ParamByName.
So you need to do the ParamByName in the OnBeforeOpen event so it gets executed every time TDBDynamicGrid calls Open.


Nicole

  • Hero Member
  • *****
  • Posts: 1009
Re: TIBDynamicGrid - Query with where dows not display.
« Reply #16 on: February 14, 2024, 05:42:37 pm »
ah!!!!!!!!!!
Thank you for the explanation.
This explains all.
Yes, I thought before opening the query, this event I never used.

As I have a working version with DBGrid in the meanwhile, I will leave it like this, but save this hint for next time.

egsuh

  • Hero Member
  • *****
  • Posts: 1520
Re: TIBDynamicGrid - Query with where dows not display.
« Reply #17 on: February 15, 2024, 08:00:55 am »
Try transaction and prepare explicitly.

Code: Pascal  [Select][+][-]
  1.       IBQuery_Kupons.SQL.Text:='Select ID_KUPON, DATUM,BETRAG, FK_EINKOMMEN ' +
  2.                                ' From TBKUPONS where FK_EINKOMMEN = :FK_EINKOMMEN';
  3.  
  4.       Transaction.Active := True;
  5.       Prepare;      
  6.  
  7.       IBQuery_Kupons.ParamByName('FK_EINKOMMEN').AsInteger:=FK_EINKOMMEN;
  8.       IBQuery_Kupons.Active:=true;

rvk

  • Hero Member
  • *****
  • Posts: 6640
Re: TIBDynamicGrid - Query with where dows not display.
« Reply #18 on: February 15, 2024, 08:47:07 am »
Try transaction and prepare explicitly.
That won't work because the TIBDynamicGrid changes the SQL internally (because of the sorting etc). At that moment the (implicit or explicit) prepare is undone and parameter is lost. So this has to be done in BeforeOpen (in case you work with a TIBDynamicGrid).


 

TinyPortal © 2005-2018