Page 1 of 1

Change the SQL query

Posted: Fri Jul 15, 2011 5:24 pm
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?

Change the SQL query

Posted: Sat Jul 16, 2011 5:05 am
by Jan
Hello Jim,

Please check following url:

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

Thank you.

Change the SQL query

Posted: Sat Jul 16, 2011 6:48 am
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;

Change the SQL query

Posted: Mon Jul 18, 2011 12:51 am
by Alex K.
Hello Jim,

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