我正在使用以下代码来尝试 SetParametr :
var report = new ReportParameter[1];
report[0] = new ReportParameter("MyName", "Raha");
var reportDataSource1 = new ReportDataSource { Name = "WpfApplication17_User", Value = _users };
_reportViewer.LocalReport.DataSources.Add(reportDataSource1);
_reportViewer.ServerReport.SetParameters(report);
_reportViewer.LocalReport.ReportPath = "../../Report1.rdlc";
_reportViewer.RefreshReport();
错误:未指定报告定义的来源
为什么是错的?
我创建了一个报告参数,参数名称是“MyName”
更新 :
我正在使用以下代码:
//var report = new ReportParameter[1];
//report[0] = new ReportParameter("MyName", "Raha");
var reportDataSource1 = new ReportDataSource { Name = "WpfApplication17_User", Value = _users };
string exeFolder = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
_reportViewer.LocalReport.ReportPath =exeFolder + @"\Reports\Report1.rdlc";
_reportViewer.LocalReport.DataSources.Add(reportDataSource1);
//_reportViewer.ServerReport.SetParameters(report);
_reportViewer.RefreshReport();
数据已显示在报告中。
但是,我正在使用以下代码:
var report = new ReportParameter[1];
report[0] = new ReportParameter("MyName", "Raha");
var reportDataSource1 = new ReportDataSource { Name = "WpfApplication17_User", Value = _users };
string exeFolder = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
_reportViewer.LocalReport.ReportPath = exeFolder + @"\Reports\Report1.rdlc";
_reportViewer.LocalReport.DataSources.Add(reportDataSource1);
_reportViewer.ServerReport.SetParameters(report);//error
_reportViewer.RefreshReport();
错误为:尚未指定报告定义的来源