100分紧急求助-RDLC报表——动态加载报表 (报表已经保存为XML,但为什么换不了XML)
100分紧急求助-RDLC报表——动态加载报表 (报表已经保存为XML,但为什么换不了XML 问题: 当每次换报表加载时 提示找不到数据源, 请问怎么清理上次的数据源,加载新的数据源。
代码如下:
string strXML;
strXML = this.richTextBox1.Text;//获得打印格式 XML
this.reportViewer1.LocalReport.LoadReportDefinition(this.GenerateRdlc(strXML));//把XML生成报表RDLC
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("myds_In_Bill", c_ds.Tables[0]));
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();
第二次加在报表
this.reportViewer1.Clear();
this.reportViewer1.LocalReport.DataSources.Clear();
// this.reportViewer1.LocalReport = null;
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();
string strXML;
strXML = this.richTextBox1.Text;//获得打印格式 XML
this.reportViewer1.LocalReport.LoadReportDefinition(this.GenerateRdlc(strXML));//把XML生成报表RDLC
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("myds_IN_Invoice", c_ds.Tables[0]));//myds_IN_Invoice
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();