title: An error occurred during local report processing in c# winforms
body: <p>I want to generate <code>RDLC Report</code> on the basis of date. I have two <code>DateTimePickers</code> and a <code>Button</code> Controls on my <code>WindowForm</code> and a <code>ReportViewer</code>. I select from and To <code>Date</code> from <code>DateTimePicker</code>and When I click on a <code>Button</code> the <code>ReportViewer</code> should load from <code>Database</code> on the basis of <code>Date</code>.</p>
  
  <p>Here is my <code>Stored Procedure</code></p>
  
  <pre><code>CREATE PROCEDURE spGetBikeSalebyDate
  (
      @FromDate   DateTime,
      @ToDate     DateTime
  )
  AS
      BEGIN
          SELECT * FROM tblSaleBike 
          WHERE DateOfPurchase BETWEEN @FromDate AND @ToDate
          ORDER BY DateOfPurchase asc
      END
  </code></pre>
  
  <p>and my <code>C#</code> code </p>
  
  <pre><code>        private void btnSearchBikeSale_Click(object sender, EventArgs e)
      {
          ShowReport();
      }
  
      private void ShowReport()
      {
          reportViewer1.Reset();
          DataTable dt = GetData(dtpSearchFromDate.Value.Date, dtpSearchToDate.Value.Date);
          ReportDataSource rds = new ReportDataSource("DataSet1", dt);
          reportViewer1.LocalReport.DataSources.Add(rds);
          reportViewer1.LocalReport.ReportPath = @"ReportSaleBikeByDate.rdlc";
          ReportParameter[] rParams = new ReportParameter[] {
              new ReportParameter("fromDate",dtpSearchFromDate.Value.Date.ToShortDateString()),
              new ReportParameter("toDate",dtpSearchToDate.Value.Date.ToShortDateString())
          };
          reportViewer1.LocalReport.SetParameters(rParams);//Error Occured Here
          reportViewer1.LocalReport.Refresh();
      }
  
      private DataTable GetData(DateTime fromDate , DateTime toDate)
      {
          DataTable dt = new System.Data.DataTable();
          using (SqlConnection con = new SqlConnection(CS))
          {
              SqlCommand cmd = new SqlCommand("spGetBikeSalebyDate",con);
              cmd.CommandType = System.Data.CommandType.StoredProcedure;
              cmd.Parameters.Add("@FromDate", SqlDbType.DateTime).Value = fromDate;
              cmd.Parameters.Add("@ToDate", SqlDbType.DateTime).Value = toDate;
              SqlDataAdapter ad = new SqlDataAdapter(cmd);
              ad.Fill(dt);
          }
          return dt;
      }
  </code></pre>
  
  <p>I have passed two parameters in <code>fromDate</code> and <code>toDate</code> in <code>ReportViewer</code>. When i put my program in a <code>debug mood</code>, and check the program and works fine i-e <code>DataTable</code> returns values correctly but when it reach to <code>SQL Parameters</code> it throws an <code>exception</code> <code>An error occurred during local report processing</code>. I don't know why because my <code>Report</code> is in the <code>root directory</code>.I am also going to attach the snapshots. Please help me out.</p>
  
  <p><a href="https://i.stack.imgur.com/GnxvH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GnxvH.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/QP7rv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QP7rv.png" alt="enter image description here"></a></p>
  
  <p><strong>Updated</strong></p>
  
  <p>This is my <code>DataSet</code> which takes two parameters</p>
  
  <p><a href="https://i.stack.imgur.com/mxAEa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mxAEa.png" alt="enter image description here"></a></p>
  
  <p>and this is <code>Report Data</code></p>
  
  <p><a href="https://i.stack.imgur.com/kyN0F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kyN0F.png" alt="enter image description here"></a></p>
  
  <p>and this is the <code>Exception Detail</code></p>
  
  <p><a href="https://i.stack.imgur.com/2V7yW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2V7yW.png" alt="enter image description here"></a></p>