2017-10-04 2 views
0

J'ai écrit un code et il donne une erreur.Crystal Report Erreur de lancement

Voici ma méthode de tâche db:

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; 
} 

Et j'appelle méthode DB à partir d'ici:

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; 

debugger code et vu, lorsque l'exécution est à: r.Database.Tables["ReceiptHeader"].SetDataSource(rDal.GetInvoiceHeader(vId));

il plaids une erreur.But datatable contient des données.

erreur

est:

'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

version de Visual Studio et rapport de cristal utilisez-vous? c'est un bug dans la version SP 21 de crystal 13. – Niladri

+0

voici la source, c'est en raison de la dépendance de la plate-forme https://answers.sap.com/questions/304272/upgrade-to-sp-21-unable-to-cast- to-interface-type.html – Niladri

Répondre

0

lorsque vous remplissez du DataAdaptor, vous devez utiliser DataSet et quand vous vous retournez devez sélectionner quelle table pour retourner

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

S'il vous plaît voir l'erreur, son problème pas de jeu de données. 'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' vers l'interface de type 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. Cette opération a échoué car l'appel QueryInterface sur le composant COM pour l'interface avec IID '{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}' a échoué en raison de l'erreur suivante: Aucune interface prise en charge (Exception de HRESULT: 0x80004002 (E_NOINTERFACE)) . –