更新时间:2023-02-16 12:17:25
示例代码:
sample code:
private void button1_Click(object sender, EventArgs e)
{
DataSet1TableAdapters.Tbl1TableAdapter tb1 = new DataSet1TableAdapters.Tbl1TableAdapter();
DataSet1.Tbl1DataTable ds = tb1.GetData();
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", ds.AsEnumerable().CopyToDataTable());
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
reportViewer1.RefreshReport();
}
private void button2_Click(object sender, EventArgs e)
{
DataSet2TableAdapters.Tbl2TableAdapter tb1 = new DataSet2TableAdapters.Tbl2TableAdapter();
DataSet2.Tbl2DataTable ds = tb1.GetData();
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource2 = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", ds.AsEnumerable().CopyToDataTable());
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.ReportPath = "Report2.rdlc";
reportViewer1.LocalReport.DataSources.Add(reportDataSource2);
reportViewer1.RefreshReport();
}