Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a reportviewer and when i run it on pageload I get this error "A data source instance has not been supplied for the data source EmployeeDataSet

What should i do?

Checkt the code onpageload
C#
ReportViewer1.ProcessingMode = ProcessingMode.Local;
       LocalReport report = ReportViewer1.LocalReport;
       report.ReportPath = "Report/Report.rdlc";
       DataSet dSet = systemBusinessLayer.PLZgetAllEmployeesInfo();
       ReportDataSource dsAllEmployees = new ReportDataSource();

        dsAllEmployees.Name = "dSet";
       dsAllEmployees.Value = "dSet";
       report.DataSources.Add(dsAllEmployees);

Below is the methos in my class
C#
#region GetALLEmployees()
       public DataSet PLZgetAllEmployeesInfo()
       {
           using (SqlConnection conn = new SqlConnection(ConnString))
           {
               SqlCommand cmd = new SqlCommand("procGetAllEmployees", conn);
               cmd.CommandType = CommandType.StoredProcedure;

               DataSet dTable = new DataSet("dSet");
               SqlDataAdapter adapter = new SqlDataAdapter(cmd);
               adapter.Fill(dTable, "dSet");

               return dTable;
           }
       }
       #endregion
Posted
Updated 4-Dec-11 14:44pm
v3
Comments
[no name] 4-Dec-11 20:44pm    
EDIT: added code block

I am also getting this type of issues but when i change the code to the following way it works fine.

this.report .LocalReport.ReportPath = "";
this.report .LocalReport.DataSources.Clear();
this.report .LocalReport.Refresh();
this.report .LocalReport.ReportPath = Server.MapPath("~/Reports/RecieptVoucherForStudent.rdlc");
ReportDataSource rptUserHeader = new Microsoft.Reporting.WebForms.ReportDataSource("DatasetName", dt);
this.report.LocalReport.DataSources.Add(rptUserHeader);
this.report.LocalReport.Refresh();

DatasetName- The Dataset is created in the App_Code Dataset
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900