Forum > Databases

TIBDynamicGrid - Query with where dows not display.

(1/4) > >>

Nicole:
There is a TIBDynamicGrid and a button for display data inside it.
The code below is part of this buttonClick.

This does display data

--- 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_Kupons.SQL.Text:='Select ID_KUPON, DATUM,BETRAG, FK_EINKOMMEN ' +                           ' From TBKUPONS';  IBQuery_Kupons.Active:=true; This does not displays data

--- 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_Kupons.SQL.Text:='Select ID_KUPON, DATUM,BETRAG, FK_EINKOMMEN ' +                           ' From TBKUPONS where FK_EINKOMMEN = :FK_EINKOMMEN';  IBQuery_Kupons.ParamByName('FK_EINKOMMEN').AsInteger:=FK_EINKOMMEN;  IBQuery_Kupons.Active:=true;
The difference is the "where". And yes, I made sure, the parameter is working by enforcing a value.

To my mind the trouble occurs where the datasource connects to the query and the DBGrid connects to the Datasource.
In the direct input of the query there is NO where-clause.

One year ago I had the problem as well, but I cannot remember the solution and my postings containing "where" are 4 pages.
Please be so kind to tell me again.
It was anything with an internal storage of the queries and components.
The solution was not so hard but not very intuitive neither.

rvk:
What type is FK_EINKOMMEN?

Are you sure ut is INTEGER in the database?
Are you sure the given variable FK_EINKOMMEN contains an integer present in the table?

Nicole:
yes and yes and yes.
The paramenter is not the problem, at least I am sure about it at the moment.

I should have something to do with IBQuey, somwhere the SQL is saved not as it should / or as I want it.
This "Spalteneditor" and "Feldeditor" and "SQL-Editor" which needs to be refreshed at every change.
Unfortunately this time I do not find out, which code has to be deleted or added although not needed.

rvk:
Then you are not showing all the relevant code.
If you fill the parameter with an existing integer for FK_EINKOMMEN then it should just work.

But you might have filled IBQuery with other things and as long as we don't see with what, it's just guessing (AGAIN).

Maybe you filled TIBQuery.Datasource. In that case your parameters are taken from that Datasource and not your assigned parameter.


--- Quote from: Nicole on February 12, 2024, 01:16:43 pm ---This "Spalteneditor" and "Feldeditor" and "SQL-Editor" which needs to be refreshed at every change.
Unfortunately this time I do not find out, which code has to be deleted or added although not needed.

--- End quote ---
BTW. Seeing that... you probably SHOULD work with TIBQuery.Datasource.
Then with every change of the current record in Datasource, your SQL will automatically follow that record depending on the WHERE.
You shouldn't use ParamByName in that case on each change.

But we see way too little of your program and code to make a judgement here.
You might want to explain what components you have and how they should interact with each other.

tonyw:

--- Quote from: Nicole on February 12, 2024, 12:45:55 pm ---There is a TIBDynamicGrid and a button for display data inside it.
The code below is part of this buttonClick.

This does display data

--- 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_Kupons.SQL.Text:='Select ID_KUPON, DATUM,BETRAG, FK_EINKOMMEN ' +                           ' From TBKUPONS';  IBQuery_Kupons.Active:=true; This does not displays data

--- 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_Kupons.SQL.Text:='Select ID_KUPON, DATUM,BETRAG, FK_EINKOMMEN ' +                           ' From TBKUPONS where FK_EINKOMMEN = :FK_EINKOMMEN';  IBQuery_Kupons.ParamByName('FK_EINKOMMEN').AsInteger:=FK_EINKOMMEN;  IBQuery_Kupons.Active:=true;
The difference is the "where". And yes, I made sure, the parameter is working by enforcing a value.

To my mind the trouble occurs where the datasource connects to the query and the DBGrid connects to the Datasource.
In the direct input of the query there is NO where-clause.

One year ago I had the problem as well, but I cannot remember the solution and my postings containing "where" are 4 pages.
Please be so kind to tell me again.
It was anything with an internal storage of the queries and components.
The solution was not so hard but not very intuitive neither.

--- End quote ---
You need to move the "ParmByName" line to the IBQueries BeforeOpen event handler. It needs to be there so that it is called everytime the IBDynamicGrid requeries the dataset.

Navigation

[0] Message Index

[#] Next page

Go to full version