title: Pass Parameter to Crystal Report in asp.net
body: <p>I was trying to pass parameter from my code behind into my crystal report but I keep getting error </p>
  
  <blockquote>
    <p>Load Report Failed</p>
  </blockquote>
  
  <p>I use dataset to pass the parameter to crystal report. My dataset has 1 column (Test1)</p>
  
  <p>here is my code in code behind</p>
  
  <pre><code>Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
      Try
          Dim path As String = Server.MapPath("~\Reports\CrystalReportTest.rpt")
          Dim rptDoc As ReportDocument = New ReportDocument
          rptDoc.SetDatabaseLogon("test", "test", "TestDB", "JulianPC", True)
          Dim a As String = "10001"
          Dim b As String = "10003"
          rptDoc.Load(path)
          rptDoc.FileName = "CrystalReportTest.rpt"
          rptDoc.SetParameterValue("Test1", a)
          CrystalReportViewer1.ReportSource = rptDoc
          CrystalReportViewer1.Visible = True
      Catch ex As Exception
  
      End Try
  End Sub
  </code></pre>
  
  <p>here is my aspx code</p>
  
  <pre><code>    &lt;CR:CrystalReportSource ID="CrystalReportSource1" runat="server"&gt;
          &lt;Report FileName="CrystalReportTest.rpt"&gt;&lt;/Report&gt;
      &lt;/CR:CrystalReportSource&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                   &lt;CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" ReportSourceID="CrystalReportSource1" AutoDataBind="True" HasPrintButton="True" HasRefreshButton="True" ReuseParameterValuesOnRefresh="True" Height="50px" Width="350px"/&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>Could anyone tell me how to fix this?</p>
  
  <p>Thanks in advance for any help</p>