Question

I have a report with a parameter that usually gets its default values by running a query that takes another parameter as it's input. This works fine when the report is run interactively.

However, I have a requirement to call this report from code where all the filters are supplied by the code. The code I have for the other parameters works fine:

   string report = "Analysis/Report.aspx?ReportPath=/MyReport";
   string fullReportPath = string.Format("{0}&LocationId={1}&BatchNumber={2}&SearchReference={3}", report, locationId, batchNumber, reference);
   RunReport(fullReportPath);

There is a drop down where the both the available values and default values are retrieved from the database via a query which has the locationId as a parameter. This is so all the values are selected by default.

What do I need to change in the report and/or the code so it works as it does now and I can supply the selected values for this drop down as a parameter?

I've found this blog post which uses the concept of internal or hidden control parameters to use when setting the values of other parameters, but the example given just sets the other parameter to a default value or leaves it blank. I need for the parameter to run the current query.

Was it helpful?

Solution

It appears that SQL Reports actually does what I want automatically - but only if the parameter with the dependent query immediately follows the first query.

We were modifying the report for other reasons and moved the offending drop down higher up the parameter list so it was second (after the query that filled in the location drop down). Having done that, the drop down was populated automatically.

The blog post I linked to in the question mentions that parameter order is important and there's a separate post about that by the same author.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top