ssrs-2008 - SSRS子报表VS2010子报表数据检索失败

标签 ssrs-2008 reporting-services

我对 ssrs 的子报表部分很陌生。我已经设置了一些与标准表以及矩阵和 tablix 控件配合良好的代码,但无法加载子报表。我总是得到同样的结果

有人有使用 Visual Studio 2010 的子报表的示例代码吗?

错误消息“子报表数据检索失败”。

尽管我尝试了很多不同的方案来尝试将数据传递到子报表中,但我的代码看起来像这样。

 private void LoadReport(string reportName)
    {
        reportViewer1.Clear();
       //http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/b039e765-3cc8-43ec-ae67-14b9656bc981
        reportViewer1.Reset();
       //设置处理模式
        reportViewer1.ProcessingMode=ProcessingMode.Local;

       //设置RDL文件
        reportViewer1.LocalReport.ReportPath = 报告名称+".rdlc";

    }

    公共(public)无效LoadReport(IEnumerable产品,字符串报告名称,字符串数据源名称)
    {
        LoadReport(报告名称);

        ReportParameter myParam = new ReportParameter("ReportParameter1", st.ToString() + "TO "+ et.ToString());
            reportViewer1.LocalReport.SetParameters(new ReportParameter[] { myParam });

        reportViewer1.LocalReport.DataSources.Add(
            新的 ReportDataSource(dataSourceName, 产品));


        reportViewer1.LocalReport.DataSources.Add(
            new ReportDataSource(dataSourceName+"子报表", products));

       //处理并渲染报告
        reportViewer1.RefreshReport();
    }

最佳答案

来自 Jin Chen Microsoft,版主用户奖章 msdn论坛上的答案 http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/5d2aed0b-ea69-4cbb-b3c4-b306a48fbc30

非常感谢!

我确实有这段代码,但我在表单设计器中添加了事件,这是我通过 GUI 事件属性窗口添加的

按照你的例子,我移动了这一行

reportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WinForms.SubreportProcessingEventHandler(this.reportViewer1_suberport1);

从 form.designer.cs 到刷新报告后,就像您在示例中所做的那样,现在它可以工作了!!!

谢谢你,感恩节,哇

reportViewer1.RefreshReport(); reportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WinForms.SubreportProcessingEventHandler(this.reportViewer1_suberport1);

 private void reportViewer1_suberport1(对象发送者,SubreportProcessingEventArgs e)
    {

        ReportDataSource r=reportViewer1.LocalReport.DataSources[0];
        e.DataSources.Add(r);

    }

关于ssrs-2008 - SSRS子报表VS2010子报表数据检索失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4261970/

相关文章:

web-services - 我的 Reporting Services 2008 Web 服务 URL 仅显示目录列表

pdf - 如何删除从 SSRS 导出的 PDF 中的空白页

reporting-services - 报告定义 (RDL) 隐藏在平铺 View 中

c# - 如何将位图图像从自定义程序集返回到 SSRS 报告?

ssrs-2008 - SSRS文本框中显示空值或空值

c# - 如何使用报表查看器从 asp 网页打开 ssrs 报表

ssrs-2008 - 批量上传图片到SSRS

visual-studio-2010 - 更改默认字体 SSRS Visual Studio

reporting-services - SSRS 2008 导出到 Excel 页码问题

reporting-services - SSRS 将数据源设置为不要求最终用户输入报告的凭据信息