[solved] IBDynamicGrid - Parameters do not work. lazarus / 16-Databases ---------------------------------------------------------------------- Nicole · 2024-08-05 16:35 To my mind, there is everything ok with all parameters and syntax. But there is a substantial error in the way I put them into events or I used them. Let us have a closer look, there is an ibdynamicGrid_Tilgung, which is linked to a ibQuery_Tilgung. its SQL reads, Code: MySQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT ID_KUPON, DATUM, FK_EINKOMMEN, BETRAG, BEZEICHNUNG, BEZEICHNUNG_LANGFROM TBKUPONS a join tbeinkommenon FK_EINKOMMEN = id_einkommenwhere (betrag > :Betrag) and (Datum > :Datum) now the first oups awaits us: If I activate allow active transcation the where clause works, if I deactive it there where clause works all the time no matter, if the switch is on or off. So where is the switch: I put it into the before_open-event and it reads (the checkbox is the switch): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ......IBQuery_TilgungBeforeOpen(DataSet: TDataSet);begin  IBQuery_Tilgung.ParamByName('Betrag').AsInteger:=1000;   if CheckBox_TilgungDatum.Checked  // es wird ab einem Datum geprüft (default "heute")       then IBQuery_Tilgung.ParamByName('Datum').AsDa teTime:=DateTimePicker_Tilgung.Date       else IBQuery_Tilgung.ParamByName('Datum').AsDateTime:=0; // oder "alles"end; probably the solution is easy for the one, who knows, how it works. ---------------------------------------------------------------------- Zvoni · 2024-08-06 06:03 IBQuery.Refresh? ---------------------------------------------------------------------- Nicole · 2024-08-06 13:04 There is no refresh. There is a beforeRefresh, beforePost... I tried beforeRefresh and it did not work. ---------------------------------------------------------------------- Zvoni · 2024-08-06 13:10 Quote from: Nicole on August 06, 2024, 03:04:57 pmThere is no refresh. There is a beforeRefresh, beforePost... I tried beforeRefresh and it did not work. Huh?? https://docwiki.embarcadero.com/Libraries/Athens/en/IBX.IBQuery.TIBQue ry_Methods I clearly see a refresh-Method.... EDIT: Might even be an idea to call "Prepare" explicitely before refreshing/opening again ---------------------------------------------------------------------- Nicole · 2024-08-07 16:36 Thank you for your answers, pls again for dummies: My issue is, that I need to set query-paramters for an IBDynamicGrid, which is different from an DBGrid, because it allows sorting. The trigger for activating the query is a button in my user interface. What I tried is to go to the object inspector and guessing, which event may work. You named "refresh" and "prepare", which I do not find in the object inspector. Does this mean, that I have to write such events and name them like this? And my parameters would be set there? What about this "allow transaction" (or similar). Should it be checked or not? Or something different? I remember, that Tony once named an event to use. Unfortunately I can neither remember which, nor find the thread any more. ---------------------------------------------------------------------- Zvoni · 2024-08-08 05:55 Quote from: Nicole on August 07, 2024, 06:36:44 pmThank you for your answers, pls again for dummies: My issue is, that I need to set query-paramters for an IBDynamicGrid, which is different from an DBGrid, because it allows sorting. The trigger for activating the query is a button in my user interface. What I tried is to go to the object inspector and guessing, which event may work. You named "refresh" and "prepare", which I do not find in the object inspector. Does this mean, that I have to write such events and name them like this? And my parameters would be set there? What about this "allow transaction" (or similar). Should it be checked or not? Or something different? I remember, that Tony once named an event to use. Unfortunately I can neither remember which, nor find the thread any more. Prepare/Refresh are NOT Events! Those are Methods of the IBQuery-Object itself! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i .....IBQuer y_Tilgung.Close;IBQuery_Tilgung.ParamByName('Datum').AsDateTime:=Blabl ablaIBQuery_Tilgung.Prepare;IBQuery_Tilgung.Open;  //Or refresh. No Idea And Transactions are NOT neccessary for pure SELECT's, so choose what works ---------------------------------------------------------------------- Nicole · 2024-08-08 18:36 It works, thank you so much. I was quite sure, that there is a very easy solution for which I am blindfolded. ---------------------------------------------------------------------- tonyw · 2024-08-13 15:40 Quote from: Nicole on August 08, 2024, 08:36:53 pm It works, thank you so much. I was quite sure, that there is a very easy solution for which I am blindfolded. Nicole, You should always set query parameters in the dataset's BeforeOpen event handler. This is good practice generally, but is essential for IBDynamicGrid. ---------------------------------------------------------------------- Nicole · 2024-08-23 18:52 Thank you for the hint. I will try it, may be you have a second hint for me? It is hard to work with it. At the moment there is a topic let us say ListCustomers. I generate a SQL-thing e.g. IBSQL_ListCustomers and a button, e.g. button_ListCustomers. In the click-event there I wirte the SQL-code and fill in the parameters. If the sql-text is in the edit field and the parameters in an event, it needs a lot of clicks more to find out, what belongs to which. Or is my style here poor as well? I never learnt programming. I am a lonely girl and learnt what I need to perform a certain task. ---------------------------------------------------------------------- tonyw · 2024-08-24 12:03 Quote from: Nicole on August 23, 2024, 08:52:38 pmThank you for the hint. I will try it, may be you have a second hint for me? Nicole, it may be that the point that you are missing is that (as a design choice) IBX always clears query parameter values when a dataset is closed. It is thus OK to do something like this: MyDataset.ParamByName('foobar').AsInteger := ... MyDataset.Active := true; but only if you do not close "MyDataset" until the form closes. If you close and re-open "MyDataset" without updating the query parameters then you get an error. A datasets may be closed and re-opened for several reasons: 1. You have done this explicitly in your program. 2. It is the "Detail" dataset in a "Master/Detail" relationship, and the Master dataset is scrolled. 3. A dynamic control (e.g. IBDynamicGrid) changes its view on the data (e.g. by clicking on a column header). The way to ensure that query parameters are always set every time a dataset is opened is to set each parameter in the Dataset's BeforeOpen eventhandler. This works because this event handler is always called when a dataset is opened or re-opened and immediately before the select query is executed. Quote from: Nicole on August 23, 2024, 08:52:38 pmIt is hard to work with it. At the moment there is a topic let us say ListCustomers. I generate a SQL-thing e.g. IBSQL_ListCustomers and a button, e.g. button_ListCustomers. In the click-event there I wirte the SQL-code and fill in the parameters. If the sql-text is in the edit field and the parameters in an event, it needs a lot of clicks more to find out, what belongs to which. Or is my style here poor as well? I never learnt programming. I am a lonely girl and learnt what I need to perform a certain task. You don't need to follow a prescribed course in order to be a successful programmer. The only course I have ever been on was in 1975 when I did a two week introductory course on AlgolW (the precursor to Pascal) in between the first year exams of my Maths degree and getting the results. What I really learnt from that course was that I liked programming and went on to have (I believe successful) career in the IT industry over the next five decades ---------------------------------------------------------------------- Nicole · 2024-08-24 13:57 Thank you so much for the explanation. I will safe it in my code-snippets, where I always look into in case of troubles. And thank you for the story about yourself. Then you really started earlier than me. I started with Pascal 2.0 and then did a huge step to Borland's  unbelievable Pascal 6.0. In between I made my master in law and worked in economy. However I must say, that law and programming are not that different of the way of thinking. After this I was blessed by this guy, who cracked all Delphi versions. After he gave up, I cracked it by myself, this was D 2007, - I hated it. Delphi XE 3 I bought. The more I used it, the more I started to hate it. And it made me anxious: Because it was online bound to the Embarcadero-server. The day, they wanted to shoot me, they have the option to do it and destroy a decade of work with a click of a mouse. Then I found Lazarus and there is my home since some years and I feel great here. And I am that grateful for this forum, which was the only way for me to make it at all. I never would have managed the migration by myself.