我创建了一个 rdlc
,我在其中使用数据集作为解决方案资源管理器中的新项目来设计我的报告。从名为 Dataset1
的 datasource
绑定(bind)我的报告后。我已经创建了它的对象并尝试使用编码填充此 datasource
。现在,当我运行以下代码时,我没有得到任何结果。
可能是什么问题?
reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
LocalReport localReport = reportViewer1.LocalReport;
localReport.DataSources.Clear();
localReport.ReportPath = @"E:\Projects\Manojp\AARFID_SSRS_Report\WindowsFormsApplication1\WindowsFormsApplication1\Local Report\rptTest.rdlc";
// DataSet dataset = new DataSet("AARFID_Report");
DataSet1 ds = new DataSet1();
// fill the Data Set from DataBase.
//ds.Tables.Remove("M_GUEST");
ds.Tables.Clear();
GetData(ref ds);
//
// Create a report data source for the sales order data
ReportDataSource rds = new ReportDataSource();
rds.Name = "AA";
rds.Value = ds.Tables[0];
localReport.DataSources.Add(rds);
// reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.RefreshReport();
localReport.DataSources.Clear();
GetData()
这样做:
connection.Open();
ad.Fill(ds,"M_GUEST");
connection.Close();
在报告 View 中,消息显示为:
A data source instance has not been supplied for the data source 'dtaset1_m_guest'
最佳答案
确保 rdl 文件中的数据集名称与报告生成器匹配!
最简单的方法是拥有一个数据集、数据源和名为“M_GUEST”的实例。另外,不要在渲染前清除数据源。
关于c# - 如何使用编码运行 rdlc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3147252/