How do you pass parameters nullto a SQL 2008 report? The code that interacts with the ReportExecution and ReportService2005 web services always throws an error when executing the method ReportExecutionService.Render()after I set the parameters (not including null) by calling the method ReportExecutionService.SetExecutionParameters():
"...This report requires a default or user-defined value for the report parameter...to run or subscribe to this report, you must provide a parameter value."
although this option is defined in the .rdl file as capable nullby default null.
Should I change my code? Change settings in a .rdl file?
var rs = new ReportExecutionService();
rs.Url= "http://Z/ReportServer/ReportExecution2005.asmx";
rs.Credentials = CredentialCache.DefaultCredentials;
rs.ExecutionHeaderValue = new ExecutionHeader();
var executionInfo = rs.LoadReport(ReportTarget, null);
var parameterList = new List<ParameterValue>();
foreach (ParameterValue parameter in Parameters)
{
parameterList.Add(parameter);
}
foreach (var expectedParameter in executionInfo.Parameters)
{
if
(
expectedParameter.Nullable &&
!parameterList.Exists(delegate(ParameterValue pv)
{ return pv.Name == expectedParameter.Name; })
)
{
var parameter = new ParameterValue();
parameter.Name = expectedParameter.Name;
parameter.Value = null;
parameterList.Add(parameter);
}
}
rs.SetExecutionParameters(parameterList.ToArray(), "en-us");
Warning[] warnings = null;
string[] streamIDs = null;
string encoding = null;
string extension = null;
string mime = null;
var content = rs.Render("PDF", null, out extension, out mime, out encoding, out warnings, out streamIDs);
source
share