16
Discussion | Обсуждение / Re: Can I use a variable from a user dialog in a dataset definition
« on: November 23, 2022, 06:33:51 PM »
I want to get data from a dialog and use that data in the datasource mysql query.
The query in the datasource tblneighborhood is select * from tblNeighborhood where `Paid Year` = 2019;
That works as you would expect.
The query suggested above: select * from tblNeighborhood where `Paid Year` = $V{id};
Produces no data when the query is tested and produces no data when run from the script.
I think mysql is looking for a text item formated like '2019'. So can we convert $V{id} to a text value? $S{id} also does not work.
function beforeDataPrint() {
setVariable("id", Dialog.txtYear.text)
reopenDatasource(tblneighborhood)
}
It appears that the variable is not evaluated by mysql or it is empty. I have been unable to visualize the variable id in a text item on the report to check it's contents.
Unfortunately I was a bit premature when I said "subst' suggestion worked. It must have been a fluke.
I still think QtRptDesigner is a good product and I will continue to use it.
Hope this helps.
Thanks
The query in the datasource tblneighborhood is select * from tblNeighborhood where `Paid Year` = 2019;
That works as you would expect.
The query suggested above: select * from tblNeighborhood where `Paid Year` = $V{id};
Produces no data when the query is tested and produces no data when run from the script.
I think mysql is looking for a text item formated like '2019'. So can we convert $V{id} to a text value? $S{id} also does not work.
function beforeDataPrint() {
setVariable("id", Dialog.txtYear.text)
reopenDatasource(tblneighborhood)
}
It appears that the variable is not evaluated by mysql or it is empty. I have been unable to visualize the variable id in a text item on the report to check it's contents.
Unfortunately I was a bit premature when I said "subst' suggestion worked. It must have been a fluke.
I still think QtRptDesigner is a good product and I will continue to use it.
Hope this helps.
Thanks