The source of the report definition has not been specified

MMD MNC picture MMD MNC · Oct 15, 2012 · Viewed 51.4k times · Source

I'm using the following code 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 wrong?

I've created a report parameter , Parameter 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 displayed in 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

Answer

Krishna Choudhari picture Krishna Choudhari · Sep 15, 2016

Put ReportParameter after the

_reportViewer.LocalReport.ReportPath = "../../Report1.rdlc";

here you write your ReportParameter