0

I am getting an error while I am trying to add data source manually through C#:

An error has occurred during report processing. Cannot create a data reader for dataset 'DataSet1'

My C# Code is:

public DataTable GetData()
    {
        DataTable dt = new DataTable();
        string conString = ConfigurationManager.ConnectionStrings["DatabaseManagerCS"].ConnectionString;

        using (SqlConnection con = new SqlConnection(conString))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter("select ApplicationID,Companyid from Applications", con))
            {
                sda.Fill(dt);
            }
        }
        return dt;
    }
}

 protected void Page_Load(object sender, EventArgs e)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report2.rdlc");                    
            ReportDataSource datasource = new ReportDataSource("Dataset1", GetData());
            ReportViewer1.LocalReport.DataSources.Add(datasource);
            ReportViewer1.LocalReport.Refresh();
        }
CKE
  • 1,533
  • 19
  • 18
  • 29
Ravi Shankar
  • 21
  • 1
  • 2
  • The Error indicates the report's data source name is "DataSet1", not "Dataset1". – Crowcoder Jun 22 '18 at 12:27
  • Possible duplicate of [.rdlc Report - Cannot create a data reader for dataset 'DataSet1'](https://stackoverflow.com/questions/15365731/rdlc-report-cannot-create-a-data-reader-for-dataset-dataset1) – Crowcoder Jun 22 '18 at 12:28

0 Answers0