Solved

SSRS Subreport VS2010 data retrieval failed for the subreport

Posted on 2010-11-23
1
3,198 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now