问题描述:c# 创建RDLC报表报表运行提示“尚未为数据源提供数据源实例”
解决方法:
1、在WinForm窗体上的reportView1的右上角点击 三角小按钮,打开ReportViewer任务窗口,选择rdlc报表,选择数据源,选择数据源实例
2、对通过代码动态建立的.ReportDataSource对象,须设置对象的Value属性,并清除系统自建但未绑定数据源的.ReportDataSource对象,示例代码如下:
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1;
reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
reportDataSource1.Name = "CrystalReportTest_DBDataSet_Table1";
reportDataSource1.Value = this.crystalReportTest_DBDataSet.Table1;//此处是引起“尚未为数据源提供数据源实例”错误提示的原因
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
this.reportViewer1.LocalReport.ReportEmbeddedResource = "LjzCrystalReportsApplication.Report2.rdlc";
this.reportViewer1.Name = "reportViewerTest";