简体   繁体   English

水晶报表抛出错误

[英]Crystal Report Throw error

I wrote a code and it gives error. 我写了一个代码,它给出了错误。

Here my db task method: 这是我的数据库任务方法:

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

And I call DB method from here: 我从这里调用DB方法:

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;

I debug code and saw, when execution comes to: r.Database.Tables["ReceiptHeader"].SetDataSource(rDal.GetInvoiceHeader(vId)); 我调试了代码,看到执行时涉及到: r.Database.Tables["ReceiptHeader"].SetDataSource(rDal.GetInvoiceHeader(vId));

it throws an error.But datatable contain data. 它抛出一个错误。但是数据表包含数据。

error is: 错误是:

'CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass' to interface type 'CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource'. 接口类型为“ CrystalDecisions.ReportAppServer.Controllers.ISCRReportSource”的“ CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass”。 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)). 此操作失败,因为具有以下错误的IID为'{98CDE168-C1BF-4179-BE4C-F2CFA7CB8398}'的接口的COM组件上的QueryInterface调用由于以下错误而失败:不支持此类接口(HRESULT的异常:0x80004002(E_NOINTERFACE)) 。

when you fill from the DataAdaptor, you have to use DataSet and when you return you have to select which table to return 从DataAdaptor进行填充时,必须使用DataSet;返回时,必须选择要返回的表

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM