?
Solved

SSRS Subreport VS2010 data retrieval failed for the subreport

Posted on 2010-11-23
1
Medium Priority
?
3,311 Views
Last Modified: 2012-06-27
Does anyone have a subreport working in visual studio 2010?

I am new to the subreport part of ssrs. I have setup some code which works well with the standard tables and matrix and tablix controls but have been unable to get the subreport to load. I keep getting the same

error message "data retrieval failed for the subreport".

My code looks like this though I have tried a bunch of different scenarios to try to pass the data into the subreport.

    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();
    }
0
Comment
Question by:pmtolk1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
pmtolk1 earned 0 total points
ID: 34214344
up vote  0  down vote accept
      

From Jin Chen Microsoft, ModeratorUsers Medals the answer on the msdn forum http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/5d2aed0b-ea69-4cbb-b3c4-b306a48fbc30

THANK YOU SO MUCH!!!

I did have this code but I had the event added in the form designer which I added via the GUI event property window thing

and following your example I moved this line

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

From the form.designer.cs to after the refresh report as you did in your example and NOW IT WORKS!!!

Thank you awesome thanksgiving, whew

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

   private void reportViewer1_suberport1(object sender, SubreportProcessingEventArgs e)
    {

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

    }
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question