Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reporting services SSRS 2008空参数_Reporting Services_Ssrs 2008 - Fatal编程技术网

Reporting services SSRS 2008空参数

Reporting services SSRS 2008空参数,reporting-services,ssrs-2008,Reporting Services,Ssrs 2008,如何将null参数传递到SQL 2008报表中?与ReportExecution&ReportService2005 web服务接口的代码在执行ReportExecutionService.Render()方法时总是产生错误,在我通过调用ReportExecutionService.SetExecutionParameters()方法设置参数(不包括可为空的参数)之后: “…此报表需要报表参数的默认值或用户定义值…要运行或订阅此报表,必须提供参数值。” 即使该参数在.rdl文件中定义为nulla

如何将
null
参数传递到SQL 2008报表中?与ReportExecution&ReportService2005 web服务接口的代码在执行
ReportExecutionService.Render()
方法时总是产生错误,在我通过调用
ReportExecutionService.SetExecutionParameters()
方法设置参数(不包括可为空的参数)之后:

“…此报表需要报表参数的默认值或用户定义值…要运行或订阅此报表,必须提供参数值。”

即使该参数在.rdl文件中定义为
null
able,并且默认为
null

我必须更改代码吗?是否更改.rdl文件中的参数选项

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);
var rs=new ReportExecutionService();
rs.Url=”http://Z/ReportServer/ReportExecution2005.asmx";     
rs.Credentials=CredentialCache.DefaultCredentials;
rs.ExecutionHeaderValue=新的ExecutionHeader();
var executionInfo=rs.LoadReport(ReportTarget,null);
var参数List=新列表();
foreach(参数中的参数值参数)
{
parameterList.Add(参数);
}
foreach(executionInfo.Parameters中的var expectedParameter)
{
如果
(  
expectedParameter.Nullable&&
!parameterList.Exists(委托(ParameterValue pv)
{return pv.Name==expectedParameter.Name;})
)
{
var参数=新参数value();
parameter.Name=expectedParameter.Name;
参数.Value=null;
parameterList.Add(参数);
}
}
rs.SetExecutionParameters(parameterList.ToArray(),“en-us”);
警告[]警告=null;
字符串[]streamIDs=null;
字符串编码=空;
字符串扩展名=null;
字符串mime=null;
var content=rs.Render(“PDF”、null、out扩展名、out mime、out编码、out警告、out streamid);
这个问题的答案有用吗?如果不是,也许更多的代码会有所帮助


HTH似乎是SSRS中的一个bug。特别是因为我有一些默认空值起作用的报告,一些报告给出了错误消息“…报告需要报告参数的默认值或用户定义值…”

无论如何,这段代码在VB中似乎对我有用

params = New ArrayList


试着在参数上启用allow blank选项,我试过了,但没有用。我知道是旧线程,但这就是我从VB传递空值所做的。虽然我没有使用DirectCast行,但只是将参数添加到(ReportParameter的)列表中,并使用SetParameters传递该列表。
Dim ssrsPrm As New Microsoft.Reporting.WebForms.ReportParameter(param.Name)
ssrsPrm.Values.Add(Nothing)
params.Add(ssrsPrm)
Me.ReportViewer1.ServerReport.SetParameters(DirectCast(params.ToArray(GetType(Microsoft.Reporting.WebForms.ReportParameter)), Microsoft.Reporting.WebForms.ReportParameter()))