【问题标题】:Cannot create a data reader for dataset 'DataSet1'无法为数据集“DataSet1”创建数据读取器
【发布时间】:2016-03-17 22:37:05
【问题描述】:
ReportViewer1.LocalReport.DataSources.Clear();
LocalReport rep = ReportViewer1.LocalReport;

ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";  //this is the name of the DataSet on your report rdlc

ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("dataset1", ObjectDataSource1));
rep.ReportPath = "Report1.rdlc";
DataSet ds = new DataSet();

【问题讨论】:

  • 我已经使用数据集通过报表向导创建了数据源。
  • 另外,我正在尝试使用 c# 在 sql server 上自动生成报告,并且它必须是基于 Web 的。最终用户需要根据日期重试数据。
  • 为什么不用这些额外的花絮更新您的问题,而不是添加 cmets Spo-dee-o-dee?
  • 尝试从名称中删除引号(DataSet1 而不是“DataSet1”)
  • 还告诉我们你的代码会发生什么。到目前为止,您问题正文中的 only 文本是代码,但没有表明您正在尝试做什么或出了什么问题。

标签: c#


【解决方案1】:
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            LocalReport rep = ReportViewer1.LocalReport;
            rep.ReportPath = "Reports/YourReport.rdl";
            rep.DataSources.Clear();

            ReportDataSource rds1 = new ReportDataSource();
            rds1.Name = "DataSet1";
            rds1.Value = dt; // Your Pass in Dataset value (type : DataTable)
            rep.DataSources.Add(rds1);
            rep.Refresh();            

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-12
    • 1970-01-01
    • 2020-04-07
    • 2019-02-16
    • 2011-02-12
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    相关资源
    最近更新 更多