Giorgi Nakeuri Giorgi Nakeuri - 1 year ago 110
C# Question

SSRS report parameter

I have a problem with rendering report with correct parameter.
We have RDL report that has date parameter with default value which is an expression "=today()".

In project i have the following code in c#

for(int i = 0; i < 15; i++)
{
serverReport.SetParameters(new ReportParameter("dt1",date.ToString()));
File.WriteAllBytes(path, serverReport.Render("PDF"));
}


For first iteration sql stored procedure is called with the default parameter and following iterations are called with passed date(i checked it with sql profiler).

I want to mension that in loop i have many other reports with exact same default date parameter but the problem is with this one. I have compared all parameter properties in 2 repors(one that works and the other that is not working properly), but they are identical. I cant find any difference.

If i delete default value "=today()" then report is working fine.
Maybe sameone had similar problem and recommend me something about this. Thanks in advance.

Answer Source

A few things to check:

SetParameters takes IEnumerable<ReportParameter> not a single ReportParameter object. Call it like this instead:

serverReport.SetParameters(new ReportParameter[] { ReportParameter("dt1", date.ToString()) } );

Make sure that the parameter does not have the available values filled in as well as the default value. If the date passed is not one of the valid values (if applied) it won't work. For example, if the available values are set to =Today then the only report that will run properly is the first one that coincidentally uses that value.

Are you sure that date.ToString() is passing an appropriate and valid date?

Does the server's report parameter match the development environment? Parameter settings aren't automatically updated so that any modifications made on the server aren't overwritten by deploying the report again. Check the server's report parameters and update if necessary, or simply delete and redeploy the report.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download