Using multiple datasets in RDLC

半城伤御伤魂 提交于 2019-12-19 21:47:46

问题


I am working on rdlc reports, and the reports work just fine. I got stuck when I added one more dataset to the rdlc file. On adding the dataset, it added a data source as well. I ran the project, and the report was no more working giving the error: A data source instance has not been supplied for the data source

Can some one please guide me on what steps to take in order to use multiple datasets. I am using Visual Studio 2012.


回答1:


Multiple Datasources are added as follows:

ReportViewer1.LocalReport.DataSources.Add(rdS);
ReportViewer1.LocalReport.DataSources.Add(rdS1);

Refer this link:

http://www.c-sharpcorner.com/UploadFile/robo60/StandaloneRDLCReports11142007183516PM/StandaloneRDLCReports.aspx

All the parts are covered in this.

Also refer this usefull discussion:

http://forums.asp.net/t/1241964.aspx




回答2:


Should be something like this--

ReportViewer.LocalReport.DataSources.Clear();
ReportViewer.LocalReport.DataSources.Add("DataSet_Name",DataTable);
ReportViewer.LocalReport.Refresh();

Important note-- the dataset name has to match the name that appears in the rdlc. To make sure you know what this is, open the rdlc in XML Editor and find out what the name of the dataset is. When you add the datasource programatically you must reference this name as it appears in the rdlc exactly.



来源:https://stackoverflow.com/questions/15826772/using-multiple-datasets-in-rdlc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!