title: Parameter values not showing up when pushing data to a Crystal report?
body: <p>I have a Crystal report that is based on a parameterized stored procedure. The report displays the value of each parameter as well as the data. In normal use, everything works well.</p>
  
  <p>I now need to add some extra functionality to my reporting application, to do some extra processing on the data returned from the stored procedure. To achieve this, I want to call the procedure from my C# code, and push the data into the report, along with the parameter values.</p>
  
  <p>As a proof-of-concept I am building a data table with dummy data and pushing it into the report. The parameter values do not appear in the report, but the dummy data does appear. What am I doing wrong?</p>
  
  <p>I'm using Crystal Reports 11.5 to build the report, and Visual Studio 2010 to build the application. The code I'm using is:</p>
  
  <pre><code>using System;
  using System.Data;
  using CrystalDecisions.CrystalReports.Engine;
  using CrystalDecisions.Shared;
  
  namespace ReportTest
  {
      class Program
      {
          static void Main(string[] args)
          {
              var fakeTable = new DataTable("report_for_date;1");
              fakeTable.Columns.Add("Name", typeof(string));
              fakeTable.Columns.Add("Amount", typeof(decimal));
  
              var row = fakeTable.NewRow();
              row["Name"] = "TEST";
              row["Amount"] = 1000;
  
              fakeTable.Rows.Add(row);
  
              var rep = new ReportDocument();
  
              rep.Load("reportfordate.rpt", OpenReportMethod.OpenReportByDefault);
  
              rep.SetDataSource(fakeTable);
  
              rep.SetParameterValue("@date", new DateTime(2010, 05, 21) );
              rep.SetParameterValue("@threshold",5);
  
              // This code prints out the expected values (set above)
              foreach (ParameterField p in rep.ParameterFields)
                  foreach(ParameterDiscreteValue v in p.CurrentValues)
                      Console.WriteLine("{0}={1}", p.Name, v.Value);   
  
              // The report PDF is generated but does not display the parameter values
              rep.ExportToDisk(ExportFormatType.PortableDocFormat,"c:/temp/hack.pdf");
          }
      }
  }
  </code></pre>