Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
628 views
in Technique[技术] by (71.8m points)

c# 4.0 - The source of the report definition has not been specified

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 + @"ReportsReport1.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 + @"ReportsReport1.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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Put ReportParameter after the

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

here you write your ReportParameter


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...