Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An error occurred during local report processing - C# Windows Form VS2010

I am trying to use SQL Server Reporting Services in Client Mode, but something is going fishy. I have two tables in database "IEPL_Attendance_DB": Employee(EmployeeID,EmployeeName) and EmployeeTimeIn(EID,Time_In,Date_Ref,StateFlag) I want to show a report in Windows Form(C# in Visual Studio 2010). The report should be the result of following query:

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;

I found this article: http://arcanecode.com/2009/03/23/using-sql-server-reporting-services-in-client-mode/, which explains step by step procedure to create report, but when i run the my project, I see following error in report window:
A data source instance has not been supplied for the data source EmployeeAttendanceReport

Here is my code:

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");

    }
}
}

Notes:
1. SQL Query is working fine and i can see the output this query in sql server management studio.
2. Here is the properties of DataSet: DataSet Properties

Please advise!

like image 997
Azeem Avatar asked Dec 17 '22 03:12

Azeem


1 Answers

I know it's two years late but I hope this can help others

I had the same issue (An error occurred during local report processing. An error occurred during report processing. DatasetName) and I found an issue with the connection string; I had to switch from using windows authentication to sql authentication, then my report worked.

Obviously the Report Data Source Name must match with the Name you are providing through the ReportDataSource object as Brian Knight suggested

like image 146
mascab Avatar answered Dec 18 '22 18:12

mascab