本地报告处理期间发生错误 - C#Windows窗体VS2010

Aze*_*eem 4 c# visual-studio-2010 sql-server-2008 windows-forms-designer reporting-services

我正在尝试在客户端模式下使用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;
Run Code Online (Sandbox Code Playgroud)

我发现这篇文章: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");

    }
}
}
Run Code Online (Sandbox Code Playgroud)

注意:
1.SQL查询工作正常,我可以在sql server management studio中看到输出此查询.
2.这是DataSet的属性: 数据集属性

请指教!

小智 9

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

我有同样的问题(在本地报告处理期间发生错误.报告处理期间发生错误.数据集名称),我发现连接字符串有问题; 我不得不从使用Windows身份验证切换到sql身份验证,然后我的报告工作.

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