本文介绍了尚未指定报告定义的来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码尝试 SetParametr :

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

为什么会出错?

我已经创建了一个报告参数,参数名称是MyName"

I've created a report parameter, the Parameters name is '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 + @"ReportsReport1.rdlc";


    _reportViewer.LocalReport.DataSources.Add(reportDataSource1);

    //_reportViewer.ServerReport.SetParameters(report);

    _reportViewer.RefreshReport();

数据已显示在报告中.

但是,我正在使用以下代码:

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

推荐答案

将 ReportParameter 放在

Put ReportParameter after the

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

在这里你写你的报告参数

here you write your ReportParameter

这篇关于尚未指定报告定义的来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 21:42