首页 > 其他 > 详细

c#报表出现“尚未为数据源提供数据源实例”解决办法 [转]

时间:2014-01-17 08:49:14      阅读:539      评论:0      收藏:0      [点我收藏+]

制作报表中,因为直接拷来用,然后修改的,出现问题。把表面上能改的,改了之后发现还是没成功,搜到一个好文章解决了。

把name改掉就好了。

 

1、rdlc文件时一个文本文件(只不过vs设计器打开时,是可视化的),用文本编辑器打开查看,有dataset节点,如下所 示,<DataSet Name=”HBQueue_JgdmBean”>,当然,dataset节点可以有多个,没用的可以删除,删除前注意备份,也要确保删除无误。记 住dataset名字。

2、问题出现在form的designer文件中(vs2005以上),不用设计器打开,用文本打开form.designer.cs文件,查看代码,在InitializeComponent方法中有类似如下代码

Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
系统自动添加的代码,如果中间改过名字,上述部分可能会出现多个dataSource,

Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
Microsoft.Reporting.WinForms.ReportDataSource reportDataSource2 = new Microsoft.Reporting.WinForms.ReportDataSource();

3、再往下看,有如下类似代码

reportDataSource1.Name = “HBQueue_JgdmBean”;
            reportDataSource1.Value = this.JgdmBeanBindingSource;

reportDataSource2.Name = “PrintClient_JgdmBean”;
            reportDataSource2.Value = null; 

            reportView1.LocalReport.DataSources.Add(reportDataSource1);

reportView1.LocalReport.DataSources.Add(reportDataSource2);
问题就出现在上面的代码中,在此不多做解释了,自行处理,则问题解决。

数据传输打通的桥梁也就在这儿了。

4、上面的JgdmBeanBindingSource很简单了,就是一个数据源绑定对象,设定好DataSource属性,即通过vs新建的数据源,一般来说,用数据对象的居多。

5、问题解决的关键就在第2点和第3点。

c#报表出现“尚未为数据源提供数据源实例”解决办法 [转]

原文:http://www.cnblogs.com/halo-sc/p/3522817.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!