title: SSRS 2008 NULL Parameters
body: <p>How do you pass in <code>null</code> parameters into a SQL 2008 Report? The code that interfaces with the ReportExecution &amp; ReportService2005 web services always yields an error upon executing the <code>ReportExecutionService.Render()</code> method, after I set the parameters (not including the nullable one) via invoking the <code>ReportExecutionService.SetExecutionParameters()</code> method:</p>
  
  <p><code>"...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."</code></p>
  
  <p>even though that parameter is defined in the .rdl file as being <code>null</code>able, and defaulting to <code>null</code>.</p>
  
  <p>Must I change my code? Change parameter options in the .rdl file?</p>
  
  <pre><code>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&lt;ParameterValue&gt;();
  
  foreach (ParameterValue parameter in Parameters)
  {
    parameterList.Add(parameter);
  }
  
  foreach (var expectedParameter in executionInfo.Parameters)
  {
    if 
    (  
        expectedParameter.Nullable &amp;&amp; 
        !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);
  </code></pre>