2017-10-04 6 views
0

Ich schrieb einen Code und es gibt Fehler.Crystal Report Throw Fehler

Hier meine db Aufgabe Methode:

public DataTable GetInvoiceHeader(string vId) 
{ 
    DataTable dt = new DataTable(); 
    using (MySqlConnection cn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["icddrb_tblabConnectionString"].ToString())) 
    { 
     String sSQL = string.Format(@"SELECT cn.`center_name` 
              ,cn.`center_address` 
              ,cn.`mobile_no` `center_mobile` 
              ,inv.`invoice_id` 
              ,pt.`pid` 
              ,inv.`invoice_date` 
              ,pt.`p_name` 
              ,pt.`age` 
              ,pt.`age_unit` 
              ,pt.`sex` 
              ,pt.`ref_by` 
              ,pt.`mobile` 
              ,un.`full_name` prepared_by 
              ,inv.sample_name, inv.collection_date_time 
          FROM `tb_invoice` inv 
          INNER JOIN `tb_patient` pt ON inv.`parient_id` = pt.`id` AND inv.id = {0} 
          INNER JOIN `tb_center` cn ON inv.`center_id` = cn.`id` 
          INNER JOIN `tb_user` un ON inv.`prepared_by` = un.`id`", vId); 

     MySqlDataAdapter da = new MySqlDataAdapter(sSQL, cn); 

     da.Fill(dt); 
     da.Dispose(); 
    } 
    return dt; 
} 

Und ich rufe DB Methode von hier:

ReportDAL rDal = new ReportDAL(); 
receipt r = new receipt(); 


// DataTable dm = rDal.GetInvoiceHeader(vId); 
//string ww = GetInvoiceHeader(vId); 

r.Database.Tables["ReceiptHeader"].SetDataSource(rDal.GetInvoiceHeader(vId)); 
r.Database.Tables["ReceiptDetails"].SetDataSource(rDal.GetInvoiceDetails(vId)); 
r.SetParameterValue("pReportDeliveryTime", GlobalData.reportDeliveryTime); 
crystalReportViewer1.ReportSource = r; 

ich Debug-Code und sah, wenn die Ausführung kommt: r.Database.Tables["ReceiptHeader"].SetDataSource(rDal.GetInvoiceHeader(vId));

wirft ein Fehler. Aber die Datentabelle enthält Daten.

Fehler ist:

'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' to interface type 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

+0

, welche Version von Visual Studio zurückzukehren und Crystal Report verwendest du? Es ist ein Fehler in SP 21 Release von Kristall 13. – Niladri

+0

Hier ist die Quelle, es ist aufgrund der Plattformabhängigkeit https://answers.sap.com/questions/304272/upgrade-to-sp-21-unable-to-cast- to-interface-type.html – Niladri

Antwort

0

, wenn Sie aus dem DataAdaptor füllen, haben Sie DataSet zu verwenden, und wenn Sie zurückkommen müssen Sie auswählen, welche Tabelle

public DataTable GetInvoiceHeader(string vId) 
{ 
    DataSet ds = new DataSet(); 
    using (MySqlConnection cn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["icddrb_tblabConnectionString"].ToString())) 
    { 
     String sSQL = string.Format(@"SELECT cn.`center_name` 
              ,cn.`center_address` 
              ,cn.`mobile_no` `center_mobile` 
              ,inv.`invoice_id` 
              ,pt.`pid` 
              ,inv.`invoice_date` 
              ,pt.`p_name` 
              ,pt.`age` 
              ,pt.`age_unit` 
              ,pt.`sex` 
              ,pt.`ref_by` 
              ,pt.`mobile` 
              ,un.`full_name` prepared_by 
              ,inv.sample_name, inv.collection_date_time 
          FROM `tb_invoice` inv 
          INNER JOIN `tb_patient` pt ON inv.`parient_id` = pt.`id` AND inv.id = {0} 
          INNER JOIN `tb_center` cn ON inv.`center_id` = cn.`id` 
          INNER JOIN `tb_user` un ON inv.`prepared_by` = un.`id`", vId); 

     MySqlDataAdapter da = new MySqlDataAdapter(sSQL, cn); 

     da.Fill(ds); 
     da.Dispose(); 
    } 
    return ds.Table[0]; 
} 
+0

Bitte beachten Sie den Fehler, es ist kein Dataset-Problem. 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' für den Schnittstellentyp 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. Diese Operation ist fehlgeschlagen, weil der QueryInterface-Aufruf der COM-Komponente für die Schnittstelle mit IID '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}' aufgrund des folgenden Fehlers fehlgeschlagen ist: Keine solche Schnittstelle unterstützt (Ausnahme von HRESULT: 0x80004002 (E_NOINTERFACE)) . –