title: Why getting this error :Specified cast is not valid
body: <p>I am using this code to open crystal report in VS2010 ,<code>axCRViewer1</code> is <code>crystal report viewer control name</code> , but getting error at this line</p>
  
  <p><code>axCRViewer1.ReportSource = rptDoc;</code></p>
  
  <p>How do I fix it ?</p>
  
  <pre><code>private void ViewR_Load(object sender, EventArgs e)
              {
                  ReportDocument rptDoc = new ReportDocument();
                  DataSetPatient ds = new DataSetPatient(); // .xsd file name
                  DataTable dt1 = new DataTable();
                  DataTable dt = DBHandling.GetPatient();//getting data using GetPatient()
  
                  // Just set the name of data table
                  dt.TableName = "Crystal Report P";
                  ds.Tables[0].Merge(dt);
  
                  // Your .rpt file path will be below
                  rptDoc.Load("C:\\Users\\Monika\\Documents\\Visual Studio 2010\\Projects\\SonoRepo\\SonoRepo\\Reports\\CrystalReportP.rpt");
  
                  //set dataset to the report viewer.
                  rptDoc.SetDataSource(ds);
                  axCRViewer1.ReportSource = rptDoc;//getting error at this line 
                  // code to get data from the DB           
              }
  </code></pre>
  
  <p><strong>Getpatient() Code</strong></p>
  
  <pre><code>public static DataTable GetPatient()
          {
              DataTable patientTable = new DataTable();
              using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=sonorepo.mdb"))
              {
                  using (OleDbDataAdapter da = new OleDbDataAdapter(@"SELECT PatientID,PFirstName FROM Patient_Registration", con))
                      da.Fill(patientTable);
              }
              return patientTable;
          }
  </code></pre>