DataTable到Microsoft报表查看器 [英] DataTable to Microsoft Report Viewer

查看:88
本文介绍了DataTable到Microsoft报表查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经初始化了5个DataTable,并将其填充在Windows窗体FReport​​中包含的reportviewer1_Load 方法中.

Hi all,

I''ve got 5 DataTables being initialized and filled in the reportviewer1_Load method, contained in a Windows Form FReport.

DataTable dtInvoiceDetails = new DataTable();
DataTable dtInvoiceDescriptionDetails = new DataTable();
DataTable dtClientDetails = new DataTable();
DataTable dtPaymentTypeDetails = new DataTable();
DataTable dtDocumentTypeDetails = new DataTable();

MySqlCommand mscInvoiceDetails = new MySqlCommand("SELECT invoice_code, dt_invoice, total_value, observation FROM tb_invoices WHERE invoice_code = \''" + _invoiceNumber + "\'';", bdConn);
MySqlCommand mscInvoiceDescriptionDetails = new MySqlCommand("SELECT detail_description, detail_value, ind_taxible FROM tb_doc_details WHERE tb_invoices_id_invoice = (SELECT id_invoice FROM tb_invoices WHERE invoice_code = \''" + _invoiceNumber + "\'');", bdConn);
MySqlCommand mscClientDetails = new MySqlCommand("SELECT company_name, company_registration, address, corporate_name FROM tb_client WHERE id = (SELECT tb_client_id FROM tb_invoices WHERE invoice_code = \''" + _invoiceNumber + "\'');", bdConn);
MySqlCommand mscPaymentTypeDetails = new MySqlCommand("SELECT payment_type_name, payment_type_description FROM tb_payment_type WHERE id = (SELECT tb_payment_type_id FROM tb_invoices WHERE invoice_code = \''" + _invoiceNumber + "\'');", bdConn);
MySqlCommand mscDocumentTypeDetails = new MySqlCommand("SELECT doc_type_cd FROM tb_doc_type WHERE id_doc_type = (SELECT tb_doc_type_id_doc_type FROM tb_invoices WHERE invoice_code = \''" + _invoiceNumber + "\'');", bdConn);

MySqlDataAdapter mscDAdtInvoiceDetails = new MySqlDataAdapter(mscInvoiceDetails);
mscDAdtInvoiceDetails.Fill(dtInvoiceDetails);

MySqlDataAdapter mscDAdtInvoiceDescriptionDetails = new MySqlDataAdapter(mscInvoiceDescriptionDetails);
mscDAdtInvoiceDescriptionDetails.Fill(dtInvoiceDescriptionDetails);

MySqlDataAdapter mscDAdtClientDetails = new MySqlDataAdapter(mscClientDetails);
mscDAdtClientDetails.Fill(dtClientDetails);

MySqlDataAdapter mscDAdtPaymentTypeDetails = new MySqlDataAdapter(mscPaymentTypeDetails);
mscDAdtPaymentTypeDetails.Fill(dtPaymentTypeDetails);

MySqlDataAdapter mscDAdtDocumentTypeDetails = new MySqlDataAdapter(mscDocumentTypeDetails);
mscDAdtDocumentTypeDetails.Fill(dtDocumentTypeDetails);



我在一个名为RepF的Windows窗体内创建了一个名为reportViewer1的Microsoft报表查看器,其中包含一个名为Report1.rdlc的报表.

在此reportViewer1代码内部,在private void reportViewer1_Load(object sender, EventArgs e) { ... }中是上面发布的代码,该代码创建DataTables并填充它们.

在我的报告(Report1.rdlc)中,我有一些字段,例如4个文本框,将包含存储在4 DataTables中的数据,以及1个表,将包含存储在5个DataTables中的1个中的数据.

我不知道的是:如何在Report1.rdlc中创建这些字段,显示在那些初始化和完整DataTables中收集的信息?

我需要通过Microsoft Report Viewer报表(在我的情况下为Report1.rdlc)打印那些DataTables中包含的数据.此报告已使用正确的设计进行配置.我只需要喂它们.

PS:我没有使用数据集.我只有那5个数据表.如果确实有必要使用数据集,我该如何创建一个数据集并将这5个数据表包含到其中

提前致谢! :)



I created a Microsoft Report Viewer, named reportViewer1, inside a windows Form named RepF, that contain a report named Report1.rdlc.

Inside this reportViewer1 code, in private void reportViewer1_Load(object sender, EventArgs e) { ... } is the code posted above which creates the DataTables and fill them.

In my report (Report1.rdlc), I have some fields like 4 Text Boxes, which will contain data stored in 4 DataTables, and 1 Table, which will contains data stored in 1 of the 5 DataTables.

what I don''t know is: How can I make these fields in my Report1.rdlc, show the information I collected in those initializes and full DataTables?

I need to print the data contained in those DataTables through a Microsoft Report Viewer report, in my case, Report1.rdlc. This report is already configured with the properly design. I just need to feed them.

PS: I am not using a DataSet. I only have those 5 DataTables. If it is really necessary to use a DataSet, how can I create a DataSet and Include those 5 DataTables into it

Thanks in advance! :)

推荐答案

似乎以下SO线程位于同一主题上:

http://stackoverflow.com/questions/1815199/c-microsoft-report-from- datatable-object [^ ]
Seems the following SO thread is on the same topic:

http://stackoverflow.com/questions/1815199/c-microsoft-report-from-datatable-object[^]


这篇关于DataTable到Microsoft报表查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆