报告(rdlc)处理期间发生错误

时间:2015-10-15 14:25:24

标签: report rdlc dynamic-rdlc-generation

我在创建RDLC报告时遇到错误。 错误是

  

“报告处理期间发生错误。           无法创建与数据源“ds_SalesQuotation”的连接。               关闭数据读取器时调用“读取”不是有效操作。                   读取器关闭时无效尝试调用Read。 “

我创建了ds_SalesQuotation.xsd文件。 在rdlc报告中,将数据集名称命名为“dsSalesQuotation”,并将datasourse设置为“ds_SalesQuotation”

我的代码在reportviewr(.aspx)

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        using (BillingAppEntities context = new BillingAppEntities())
        {
            var val = context.Sp_SalesQuotation(id);
            ReportDataSource rd = new ReportDataSource("dsSalesQuotation", val);
            ReportViewer1.LocalReport.DataSources.Add(rd);
            ReportViewer1.LocalReport.Refresh();
}
   }
    }

我的代码中是否有任何错误。请检查任何人..

1 个答案:

答案 0 :(得分:0)

我收到了错误。我重写了上面的代码,如下所示。

现在正在运作

 private void PopulateReport(int id)
    {
        List<Sp_SalesQuotation_Result> ls = new List<Sp_SalesQuotation_Result>();
        using (BillingAppEntities context = new BillingAppEntities())
        {
            ls = context.Sp_SalesQuotation(id).ToList();              
        }
        ReportDataSource rd = new ReportDataSource("dsSalesQuotation", ls);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(rd);
        ReportViewer1.LocalReport.Refresh();
    }
相关问题