.rdlc Report - Cannot create a data reader for dataset 'DataSet1'

54,125

Solution 1

I have same problem that "Cannot create a data reader for dataset 'zzz'"

The answer is ReportDataSource(string xxx, DataTable yyy)

You should use the right name. xxx should be zzz

Solution 2

My 'gotcha' was the discovery that DataSet was not the same as Dataset.

Solution 3

enter image description here

enter image description here

You have to give "DataSet1", otherwise it will not work.

Solution 4

You unable to create ReportViewer and providing true dataset. It's possible you are getting the error due to parameter providing technique

You can try like this; I solved by using this way:

   protected void btnPdf_Click(object sender, EventArgs e)
    {
    ReportViewer viwer = new ReportViewer();
    ObjectDataSource ob = new ObjectDataSource("dataset.YourTableAdapter", "GetData");
    dataset.YourTableAdapter ds = new dataset.YourTableAdapter();

    string PDF = "PDF";
    string ReportType = "ReportType";
    Warning[] warnings = null;
    string[] streamIds = null;
    string mimeType = string.Empty;
    string encoding = string.Empty;
    string extension = string.Empty;
    string filetype = string.Empty;

   

    viwer.SizeToReportContent = true;
    viwer.LocalReport.ReportPath = "reports/report/report.rdlc";
    viwer.ProcessingMode = ProcessingMode.Local;
    ob.SelectParameters.Clear();
    ob.SelectParameters.Add(QueryStringEnum.CompanyID, CurrentCompanyID.ToString());
 
    ReportDataSource rds = new ReportDataSource("datasetname", (object) ds.GetData((long?)CurrentCompanyID.ToInt64());

    viwer.LocalReport.DataSources.Add(rds);
    viwer.LocalReport.Refresh();

    byte[] bytes = viwer.LocalReport.Render("PDF", null,
     out mimeType, out encoding, out extension, out streamIds, out warnings);
   



}

Solution 5

  1. Make sure that you are running on administrator mode and you have access to the SSRS server.

  2. Verify if you have set the correct dataset name or if you are properly loading and assigning it.

Please check this sample on MSDN.

Share:
54,125
Thomas
Author by

Thomas

Hi! I'm Thomas. Currently Full Stack Developer at hobex payment systems ...

Updated on March 03, 2021

Comments

  • Thomas
    Thomas over 3 years

    I have created a .rdlc-Report under VS 2012 using the report wizard and added data source and dataset. When I try to render the report using the code below I get following error message:

    Cannot create a data reader for dataset 'DataSet1'.

    bytes = localReport.Render("PDF", sdeviceinfo, out smimetype, out sencoding, out sfilenameextension, out streamids, out myWarnings);