I'm using the following code with which I'm trying to 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();
error : The source of the report definition has not been specified
Why is it wrong?
I've created a report parameter, the Parameters name is 'MyName'
UPDATE :
I'm using the following code :
//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();
data has displayed in the Report.
but , I'm using the following code :
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();
error as : The source of the report definition has not been specified
The error is not related to your parameter. The error is related to the
ReportPath
. See this other SO question regarding setting the report path. Are you sure the relative path you have specified is correct when your application is running. Is that path relative to your source code? If you want to see where it is looking for the file then you can add some code to resolve that relative path (Path.GetFullPath) and see where it is pointing. Make sure yourrdlc
file is in that folder.Edit:
Based on your updated question and verifying that the report is actually being found. I looked in more detail at your code. You are setting the parameters for the
ServerReport
, but you are loading the report in theLocalReport
. Trying setting the parameters in theLocalReport
.