Ssrs 2008 子报表的SSRS子报表VS2010数据检索失败

Ssrs 2008 子报表的SSRS子报表VS2010数据检索失败,ssrs-2008,reporting-services,Ssrs 2008,Reporting Services,我不熟悉ssrs的子报告部分。我已经设置了一些代码,这些代码与标准表、矩阵和tablix控件配合得很好,但无法加载子报表。我一直都是这样 有人有使用VisualStudio2010的子报表的示例代码吗 错误消息“子报表的数据检索失败” 我的代码看起来是这样的,尽管我尝试了一系列不同的场景来尝试将数据传递到子报表中 private void LoadReport(string reportName) { reportViewer1.Clear();

我不熟悉ssrs的子报告部分。我已经设置了一些代码,这些代码与标准表、矩阵和tablix控件配合得很好,但无法加载子报表。我一直都是这样

有人有使用VisualStudio2010的子报表的示例代码吗

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

我的代码看起来是这样的,尽管我尝试了一系列不同的场景来尝试将数据传递到子报表中

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

        // Set RDL file
        reportViewer1.LocalReport.ReportPath = reportName+".rdlc";

    }

    public void LoadReport(IEnumerable products, string reportName, string dataSourceName)
    {
        LoadReport(reportName);

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

        reportViewer1.LocalReport.DataSources.Add(
            new ReportDataSource(dataSourceName, products));


        reportViewer1.LocalReport.DataSources.Add(
            new ReportDataSource(dataSourceName+"Subreport", products));

        // Process and render the report
        reportViewer1.RefreshReport();
    }

来自金晨微软,版主 msdn论坛上的答案

非常感谢你

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

按照你的例子,我移动了这条线

reportViewer1.LocalReport.SubreportProcessing+=新的Microsoft.Reporting.WinForms.SubreportProcessingEventHandler(this.reportViewer1_suberport1)

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

谢谢你,很棒的感恩节


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


我没有发现将事件处理程序移动到其他位置对这个特定错误有帮助。对于这个错误,修复它的方法是什么,那么您必须确保您的子报表可以在没有错误的情况下运行。然后,将其与主报告联系起来。在我的例子中,我的报告在IDE中使用的数据集与我在代码中提供的数据集不同

   private void reportViewer1_suberport1(object sender, SubreportProcessingEventArgs e)
    {

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

    }