如何使用编码运行 rdlc
我创建了一个 rdlc,其中使用数据集作为解决方案资源管理器中的新项目来设计我的报告。从名为 Dataset1
的数据源
绑定我的报告后。我已经创建了它的对象并尝试使用编码来填充此数据源。现在,当我运行以下代码时,我没有得到任何结果。
可能是什么问题?
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();
在报告视图中,消息显示为:
尚未为数据源“dtaset1_m_guest”提供数据源实例
I have created an rdlc
where I have used dataset taken as a new item in solution explorer for designing my report. After binding my report from that datasource
which is named as Dataset1
. I have created its object and tried to fill this datasource
using coding. Now when I runs the following code I am not getting any result.
What can be the issue?
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()
do this:
connection.Open();
ad.Fill(ds,"M_GUEST");
connection.Close();
In the report view a message is shown as:
A data source instance has not been supplied for the data source 'dtaset1_m_guest'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果绑定中的数据源名为“Dataset1”,那么您在代码中的数据源也应命名相同。
我添加它就像这样完美地执行此操作,如下所示:
If the DataSource in binding is named "Dataset1" then the one you your in code should also name the same.
I add it like this works perfectly do this as below:
当您通过向导在项目中添加 .rdlc 报告时,默认情况下它将数据集名称设为 'DataSet1' 。现在,如果您想动态绑定新数据集,则该数据集的名称必须是“DataSet1”。尝试更改它,并检查 Table[0] 是否包含一些数据(行),其数据类型与“DataSet1”的原始数据类型匹配。如果数据类型不匹配,则数据将不会出现在您的 ReportViewer 中。尝试此代码:-
有关 .rdlc 报告(核心逻辑)的更多详细信息,请参阅以下链接
如何在没有数据库的情况下创建报告(RDLC)?
When you add .rdlc report in your project by wizard then by default it take dataset name as 'DataSet1' . Now if you want to bind dynamically new dataset then name of that dataset must be 'DataSet1'. Try change it and also check that Table[0] contains some data(Rows) for which DataType get matched with original dataType of 'DataSet1'. If DataType doesn't matches then data wont come in your ReportViewer. Try this code:-
For more detail about .rdlc report(Core logic) refer following link
How to create report (RDLC) without database?
该行
必须与报告中定义的数据集名称匹配。在你的情况下,那就是
This line
must match the name of the data set defined in the report. In your case, that would be
确保 rdl 文件中的数据集名称与报告生成器匹配!
最简单的方法是拥有一个数据集、数据源和名为“M_GUEST”的实例。另外,渲染前不要清除数据源。
Make sure the names of datasets in the rdl file and the report generator match!
The easiest way would be to have a DataSet, DataSource and the instances named "M_GUEST". Also, do not clear the data sources before rendering.