我想在客户端模式下使用SQL Server Reporting Services,但有些事情会发飙。 我有两个表在数据库“IEPL_Attendance_DB”: 员工(EmployeeID,EmployeeName)和EmployeeTimeIn(EID,Time_In,Date_Ref,StateFlag) 我想在Windows窗体(Visual Studio 2010中的C#)中显示报表。该报告应该是下面的查询结果:在本地报告处理过程中出现错误 - C#Windows窗体VS2010
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的属性:
请指教!
应该“EmployeeAttendanceReport_EmployeeAttendanceReport”与“EmployeeAttendanceReport”在你的设置代码的C#部分取代dsCustomers.Name? – RThomas 2012-02-15 17:58:46
将名称更正为EmployeeAttendanceReport后,出现以下错误:
“本地报告处理过程中发生错误
报告处理过程中出现错误
EmployeeAttendanceReport” – Azeem 2012-02-15 18:36:17
请问您可以在[报告期间发生的错误处理。在ASP.NET MVC中的RLDC报告](http://stackoverflow.com/questions/28966954/an-error-occurred-during-report-processing-rldc-reporting-in-asp-net-mvc)? – 2016-04-24 20:26:53