SSRS report parameter

给你一囗甜甜゛ 提交于 2019-12-14 03:30:16

问题


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.


回答1:


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.




回答2:


Try to completely remove the not working report within the server (and to test,also one of the working) and re-deploy both to the server. you could also check in reporting manager for the parameter settings, because there the difference might be visible.

I had that kind of issues before with report parameters and know that the parameter settings are not overwritten correctly all the time you deploy the report.



来源:https://stackoverflow.com/questions/27900996/ssrs-report-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!