Forum > Databases

[solved] IBDynamicGrid - Parameters do not work.

<< < (2/3) > >>

Zvoni:

--- Quote from: Nicole on August 07, 2024, 06:36:44 pm ---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.

--- End quote ---
Prepare/Refresh are NOT Events!
Those are Methods of the IBQuery-Object itself!


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---.....IBQuery_Tilgung.Close;IBQuery_Tilgung.ParamByName('Datum').AsDateTime:=BlablablaIBQuery_Tilgung.Prepare;IBQuery_Tilgung.Open;  //Or refresh. No Idea
And Transactions are NOT neccessary for pure SELECT's, so choose what works

Nicole:
 :D :D :D :D ;D ;D ;D

It works, thank you so much.
I was quite sure, that there is a very easy solution for which I am blindfolded.

tonyw:

--- Quote from: Nicole on August 08, 2024, 08:36:53 pm --- :D :D :D :D ;D ;D ;D

It works, thank you so much.
I was quite sure, that there is a very easy solution for which I am blindfolded.

--- End quote ---

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:
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:

--- Quote from: Nicole on August 23, 2024, 08:52:38 pm ---Thank you for the hint.

I will try it, may be you have a second hint for me?

--- End quote ---
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 pm ---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.

--- End quote ---
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

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version