Change the SQL query

Stimulsoft Reports.WPF discussion
Post Reply
Jim
Posts: 5
Joined: Fri Jul 15, 2011 5:20 pm

Change the SQL query

Post by Jim »

Hi I see that parameters can be specified for the SQL query, example:

stiReport["@countryID"] = "UK";

In this case, the designer has a Parameter called "@countryID" and the data source's query text is "select * from customers where country=@countryID".

What I want to do is to be able to change the whole where clause, not just one item. I want the query text to be "select * from customers @where" and then be able to change the code to say stiReport["@where"] = "where country = 'UK'". Is this possible? What's the best way to accomplish this?
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Change the SQL query

Post by Jan »

Hello Jim,

Please check following url:

http://stimulsoft.helpserve.com/index.p ... ticleid=71

Thank you.
Jim
Posts: 5
Joined: Fri Jul 15, 2011 5:20 pm

Change the SQL query

Post by Jim »

Thank you, it works great. I've changed my sql query string to

Code: Select all

"select * from customers {query}"
Then I used the following code to add in the query variable during runtime, so that the same code will work on different report files without needing to add the variable each time.

Code: Select all

String QueryString = "where country='UK' or country='USA'";

report.Dictionary.Variables.Add(new Stimulsoft.Report.Dictionary.StiVariable("query", ""));

report["query"] = QueryString;
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Change the SQL query

Post by Alex K. »

Hello Jim,

Ok.
Let us know if you need any additional help.
Post Reply