Page 1 of 1

List Variable as query parameter

Posted: Fri May 26, 2017 11:37 pm
by cbrydon
Hi,
I have a sample report attached with a sample database. In the report I have a list variable (varResType) where users can choose a resource type (Labor, Equipment or Material).
I'd like to be able to pass what the user chooses to a query using a parameter. Something like the following... select count(*) as RCnt from Test_Data WHERE RESOURCE_TYPE in (@paramResType).

I have the parameter setup as a varchar with a size of 50. The parameter expression I use is a string variable called varResChosen. I set the value of varResChosen in the BeforeRender event of the report with the following expression... varResChosen = varResType.ToQueryString().

Unfortunately I can't get the value of the parameter to be recognized in the query - eventhough it appears to be in the correct format. I've added columns to the report displaying the value of the varResType,varResChosen, and @paramResType and they all seem to be correct. No matter what I try, the row count is always 0. If I manually type in the parameters such as... select count(*) as RCnt from Test_Data WHERE RESOURCE_TYPE in ('LABOR','MATERIAL') I get a correct number of rows returned from the query.

I have tried setting the datatype of the parameter to be Text, but that doesn't help. Maybe I should be trying to set the value of varResChosen in a different event,
or maybe I should be going about this in a different way.

I'm using Stimulsoft Reports.Web build 2015.3 with Flash Player 25.

I hope someone can point me in the right direction.

Re: List Variable as query parameter

Posted: Mon May 29, 2017 10:00 am
by Alex K.
Hello,

Please check the sample report in the attachment.

Thank you.

Re: List Variable as query parameter

Posted: Mon May 29, 2017 1:17 pm
by cbrydon
Very Nice Aleksey - that worked. Thank You!

Re: List Variable as query parameter

Posted: Tue May 30, 2017 4:08 am
by Andrew
Hello,

Perfect. Thank you for letting us know about this.

Re: List Variable as query parameter

Posted: Fri Oct 06, 2017 4:21 pm
by cbrydon
Hi,

I have a similar question that I asked in May.

using the ListInQuery.mrt file you provided, is is possible to populate the var1 variable at run-time instead of design-time?
What I tried to do is leaving the Request From User checkbox for var1 unchecked and then populating the var1 variable in the
report BeginRender event using statements similar to the following....

var1.Add("Products");
var1.Add("Categories");

Unfortunately this doesn't seem to work - I got no results. Is it possible to do what I'm trying?

Carl

Re: List Variable as query parameter

Posted: Fri Oct 06, 2017 6:26 pm
by cbrydon
Could one option be to avoid using variables altogether, and just enter a list of string values in the expression box for a query parameter?
I also have a couple of questions noted in the attached screenshot.

Carl

Re: List Variable as query parameter

Posted: Tue Oct 10, 2017 9:51 am
by Alex K.
Hello,

Unfortunately, it is not possible to set string values in the parameters expression. You should use a variable in this case.

Thank you.

Re: List Variable as query parameter

Posted: Thu Oct 12, 2017 12:51 pm
by cbrydon
OK Alex - Thanks for the guidance!

Re: List Variable as query parameter

Posted: Thu Oct 12, 2017 7:03 pm
by Alex K.
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.