【问题标题】:The Report Definition for report has not been specified尚未指定报告的报告定义
【发布时间】:2021-09-14 00:59:30
【问题描述】:

大家好!希望你们一切顺利,我正在做我最后一年的项目,但我被困在最后一个阶段,即报告。我尝试使用 this 教程使用 RDLC 报告。

但是当我运行时它给了我这个错误;

An Error Occured during local error processing
The report definition for report "report1" has not been specified
Object reference not set to an instance of an object.

这是我的示例报告(我使用报告查看器的简单形式)代码;

using System;
using System.Windows.Forms;

namespace StockRegisterManagementSystem.Views
{
    public partial class SampleReportForm : Form
    {
        public SampleReportForm()
        {
            InitializeComponent();
        }

        private void SampleReportForm_Load(object sender, EventArgs e)
        {
           // TODO: This line of code loads data into the 'sampleDataSet1.item_procedure' table. You can move, or remove it, as needed.
            this.item_procedureTableAdapter.Fill(this.sampleDataSet.item_procedure);
           
            this.reportViewer1.RefreshReport(); 
        }

    }
}

我已经在 StackOverflow

上看到了以下答案

The report definition for report ' ' has not been specified

你知道当你处于最后阶段但无法继续前进时是多么痛苦????????????。

提前致谢 ;)

【问题讨论】:

标签: c# visual-studio entity-framework stored-procedures rdlc


【解决方案1】:

我根据您使用的文档进行了测试,没有重现您的问题。您可以尝试检查我的以下步骤,看看它们是否与您的一致。

  1. 在 Visual Studio 2019 中创建名为 RDLC 的 Windows 窗体应用 (.NET Framework) 项目。
  2. 创建 Report.rdlc: 右击项目名称 -> 选择添加 -> 点击新建项目... -> 搜索并选择报告 -> 命名为 Report1.rdlc -> 点击添加。
  3. 创建 DataSet.xsd: 右键项目名称->选择添加->点击新建项目...->搜索并选择数据集->命名DataSet1.xsd->点击添加。
  4. 将数据添加到 DataSet.xsd(我使用的是 SQL Server 对象资源管理器中的现有数据): 点击查看->选择SQL Server对象资源管理器->复制备库服务器名。

在空白区域右击->选择添加新表适配器->点击新建连接...->将服务器名称粘贴到服务器名称中->选择要使用的数据库名称。

单击 Enter a SQL Statement 页面旁边的 Next-> 单击 Query Builder...-> 选择要使用的数据表 -> 单击 Add,然后单击 Close。

勾选*(所有列)->点击添加

  1. 将数据添加到 Rerport1.rdlc[Design]: 打开Report.rdlc[Design]->右键选择Insert->点击Matrix->add data to Matrix。

  1. 添加 Nuget 包以使用 ReportViewer: 右键项目名称->选择Manage Nuget Packages...->点击浏览->进入并搜索下载包Microsoft.ReportingServices.ReportViewerControl.Winforms
  2. 在 Form1.cs[Design] 页面下 -> 在 Toolbox 中搜索并添加 ReportViewer。

  1. Form1.cs的代码:

    使用系统; 使用 System.Windows.Forms; 命名空间 rdlc { 公共部分类Form1:表格 { 公共表格1() { 初始化组件(); } 私人无效Form1_Load(对象发送者,EventArgs e) { this.AddressTableAdapter.Fill(this.DataSet1.Address); this.reportViewer1.RefreshReport(); } } }

  2. 结果如图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多