* * *

Author Topic: [SOLVED] IBX for Lazarus, parameter AsDateTime problem  (Read 791 times)


  • Full Member
  • ***
  • Posts: 100
    • MWA Software
Re: IBX for Lazarus, parameter AsDateTime problem
« Reply #15 on: March 13, 2018, 03:21:46 pm »
Hi Tony !

Here is a test program based on the Employee database, tested ...
At first it seems to have worked for me, but when I started it again, it did not work after the date change. The monitor tab can look at the execution SQL result ...
I can see now where the problem lies. You are using a TIBDynamicGrid and that only works if the parameter values are set in the BeforeOpen event handler. Although that is how all the examples work, I would agree that this should be clearer in the documentation. The same constraint applies to the other IBX dynamic controls.

The reason for this is that they are designed to manipulate the SQL Query behind the scenes - closing and re-opening the dataset. TIBDynamicGrid does this in order to modify the SQL order by clause so that you can re-order the grid by simply clicking on the column heading. However, when the SQL is changed, behind the scenes or otherwise, TIBQuery clears its parameters and re-parses the SQL losing any settings made before you call TIBQuery.Open. If you set the parameters in the BeforeOpen handler then this is again called after the TIBDynamicGrid has updated the SQL and are hence always applied.

In theory it would be possible to save the parameter settings while TIBDynamicGrid does its work and then re-apply them if the number of parameters, their name and type have not changed. However, I personally prefer to update the documentation and make this constraint clearer.

On the other hand, you could always use a standard TDBGrid as this should work with your code - but then you lose dynamic column sizing and sorting.

Also worth noting that by turning off monitoring as soon as the dataset is opened, you missed all the dynamic SQL management that goes on. It you comment out the Disable Monitoring then you actually start to see what is happening e.g. when you click on a column header.


  • Full Member
  • ***
  • Posts: 150
Re: [SOLVED] IBX for Lazarus, parameter AsDateTime problem
« Reply #16 on: March 13, 2018, 08:52:17 pm »
Ok, thanks to clarifying the things, honestly I don't expect that DynamicGrid is working in that way. Now I know what to expect and on my own is to decide where and when to use this special controls. Yes you are right about standard DBGrid, it's working as expect in my sample code.

Thanks, I learned again something useful  !



Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus