尚未指定报表定义的来源 [英] The source of the report definition has not been specified

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

问题描述

我使用以下代码尝试SetParametr:

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

为什么会错?

我创建了一个报表参数,参数名称为'MyName'

I've created a report parameter , Parameter name is 'MyName'

UPDATE:

我使用下面的代码:

    //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();

但显示在报表中的



,我使用下面的代码:

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

推荐答案

错误与您的参数无关。该错误与 ReportPath 相关。有关设置报告路径的信息,请参见此其他SO问题。您确定您在应用程序运行时指定的相对路径是正确的。是相对于你的源代码的路径吗?如果你想看看它在哪里寻找文件,那么你可以添加一些代码来解析相对路径( Path.GetFullPath ),并查看它指向的位置。确保您的 rdlc 文件在该文件夹中。

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 your rdlc file is in that folder.

编辑
根据您更新的问题并验证是否实际找到了报告。我更详细地看了你的代码。您正在设置 ServerReport 的参数,但您要在 LocalReport 中加载报告。尝试在 LocalReport 中设置参数。


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 the LocalReport. Trying setting the parameters in the LocalReport.

_reportViewer.LocalReport.SetParameters(report);

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆