Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
490 views
in Technique[技术] by (71.8m points)

c# - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...