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
Solved

SSRS Subreport VS2010 data retrieval failed for the subreport

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

765 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