我想在客戶端模式下使用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