【问题标题】:An error occurred during local report processing - C# Windows Form VS2010本地报表处理时出错-C# Windows Form VS2010
【发布时间】:2012-02-15 17:37:09
【问题描述】:

我正在尝试在客户端模式下使用 SQL Server Reporting Services,但出现问题。 我在数据库“IEPL_Attendance_DB”中有两个表: Employee(EmployeeID,EmployeeName) 和 EmployeeTimeIn(EID,Time_In,Date_Ref,StateFlag) 我想以 Windows 窗体(Visual Studio 2010 中的 C#)显示报告。报告应该是以下查询的结果:

select e1.EID,e.EmployeeName,convert(varchar(5),SUM(e1.HoursConsumed)/3600)+':'+convert(varchar(5),SUM(e1.HoursConsumed)%3600/60)+':'+convert(varchar(5),(SUM(e1.HoursConsumed)%60)) as workingtime, CONVERT(VARCHAR(10),e1.Date_Ref,111) as Date_Ref
from Employee as e, EmployeeTimeIn as e1
where e.EmployeeID = e1.EID
group by e1.Date_Ref,e1.EID,e.EmployeeName;

我找到了这篇文章:http://arcanecode.com/2009/03/23/using-sql-server-reporting-services-in-client-mode/,它解释了创建报告的分步过程,但是当我运行我的项目时,我在报告窗口中看到以下错误:
尚未为数据源 EmployeeAttendanceReport 提供数据源实例

这是我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//Add these to the standard list above
using System.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Reporting.WinForms;

namespace EmployeeManager
{
public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

        //this.reportViewer1.RefreshReport();

        // Set the processing mode for the ReportViewer to Local
        reportViewer1.ProcessingMode = ProcessingMode.Local;

        LocalReport localReport = reportViewer1.LocalReport;
        localReport.ReportPath = @"F:\Muhammad Anees\Time In\WpfApplication1\EmployeeManager\AttendanceReport.rdlc";

        DataSet dataset = new DataSet("EmployeeAttendanceReport");

        // Get the sales order data
        GetCustomerOrders(ref dataset);

        // Create a report data source for the sales order data
        ReportDataSource dsCustomers = new ReportDataSource();
        dsCustomers.Name = "EmployeeAttendanceReport_EmployeeAttendanceReport";
        dsCustomers.Value = dataset.Tables["Employee"];

        localReport.DataSources.Add(dsCustomers);

        // Refresh the report
        reportViewer1.RefreshReport();
    }

    private void GetCustomerOrders(ref DataSet dsNorthwind)
    {
        string sqlCustomerOrders = "SELECT e1.EID"
          + " ,e.EmployeeName"
          + " ,CONVERT(VARCHAR(10),e1.Date_Ref,111) as Date_Ref"
          + " ,convert(varchar(5),SUM(e1.HoursConsumed)/3600)+':'+convert(varchar(5),SUM(e1.HoursConsumed)%3600/60)+':'+convert(varchar(5),(SUM(e1.HoursConsumed)%60)) as workingtime"
          + "  FROM Employee as e, EmployeeTimeIn as e1"
          + "  WHERE e.EmployeeID=e1.EID"
          + "  GROUP BY e1.Date_Ref,e1.EID,e.EmployeeName";

        SqlConnection connection = new
          SqlConnection("Data Source=AZEEMPC; " +
                        "Initial Catalog=IEPL_Attendance_DB; " +
                        "Trusted_Connection = true;");

        SqlCommand command =
            new SqlCommand(sqlCustomerOrders, connection);

        SqlDataAdapter EmployeeAttendanceReportAdapter = new
            SqlDataAdapter(command);

        EmployeeAttendanceReportAdapter.Fill(dsNorthwind, "EmployeeAttendanceReport");

    }
}
}

注意事项:
1. SQL 查询工作正常,我可以在 sql server management studio 中看到此查询的输出。
2.DataSet的属性如下:

请指教!

【问题讨论】:

  • 是否应该在您设置 dsCustomers.Name 的代码的 c# 部分中将“EmployeeAttendanceReport_EmployeeAttendanceReport”替换为“EmployeeAttendanceReport”?
  • 将姓名更正为EmployeeAttendanceReport后,出现以下错误:
    “本地报告处理过程中发生错误
    报告处理过程中发生错误
    EmployeeAttendanceReport”

标签: c# visual-studio-2010 sql-server-2008 reporting-services windows-forms-designer


【解决方案1】:

我知道这已经晚了两年,但我希望这可以帮助其他人

我遇到了同样的问题(本地报告处理过程中发生错误。报告处理过程中发生错误。DatasetName)我发现连接字符串有问题;我不得不从使用 windows 身份验证切换到 sql 身份验证,然后我的报告才起作用。

显然,报表数据源名称必须与您通过 ReportDataSource 对象提供的名称匹配,正如 Brian Knight 建议的那样

【讨论】:

  • 谢谢,我在使用 SQL 身份验证时遇到了用户名和密码为空的问题。
  • 帮了我一把。谢谢!
  • 帮了我一把。谢谢@mascab
  • 谢谢!我什至没有得到“DatasetName”,只有前两行。如果它对其他人有帮助:mascab 的错误可能是由于共享数据源共享数据集的共享数据源。一直拉着我的头发,直到我发现我的共享集的共享源被破坏了,除了主要的共享源。
  • 我没有得到这个错误的“DatasetName”部分,所以这个答案和它的 cmets 让我很头疼。从 TFS 工作,因此必须检查要编辑的每个共享数据源,并打开每个他们选择了 SQL Auth 并使用空白凭据的数据源。全部切换回 Windows Auth 并报告预览/运行良好。谢谢!
【解决方案2】:

您的报告数据源名称与您在 ReportDataSource 类的 Name 属性中提供的名称似乎不匹配。该报告需要 EmployeeAttendanceReport。您可能想尝试将代码中的 Name 属性设置更改为:

dsCustomers.Name = "EmployeeAttendanceReport";

【讨论】:

  • 将姓名更正为EmployeeAttendanceReport后,出现以下错误:
    本地报表处理过程中出错
    报表处理过程中出错
    EmployeeAttendanceReport
  • 我相信您现在在报表服务器端看到了错误。检查日志以了解实际错误。您的 .rdl 中可能存在问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-18
相关资源
最近更新 更多