Click here to Skip to main content
Click here to Skip to main content

SSRS - Error: Subreport could not be shown

, 13 Nov 2011
Rate this:
Please Sign up or sign in to vote.
Error trying to get SubReports to show (code in Vulcan.net)

When trying to get a subreport to show, I found many links on the web all saying one basic thing. In order to show a sub report, you must make sure the parameters are all handled and you must also hook the SubreportProcessing event so you can set the datasource. The code ran fine from the report server, it was only when the report was run in LOCAL mode that it had any issues.

Here is the final solution. When you develop reports in SSBI, the reports are created with the extension of .rdl. That normally works fine when you run them, locally. But if you define subreports, they will get the "Error trying to get SubReport to show" message. Make a copy of your subreport and in that copy, change the extension from rdl ro rdlc and your problem will go away (assuming that you have the correct parameters and you are handing the SubreportProcessing event). That is all there is to it.

// This is the Vulcan.net language - xbase to the next level
#USING System.Windows.Forms
#USING System.Data
#USING ReportViewer
#using Microsoft.Reporting.Winforms
#USING wmConsulting.SFM.DataInterface	// this is the business classes

CLASS DailySalesReport INHERIT _frmReportViewer
// ******************************************************************            
      CONSTRUCTOR()
         SUPER()
         RETURN        
// ******************************************************************            
// ******************************************************************            
METHOD SetupReport(nUnitKey AS LONG, cDate AS STRING) AS VOID
    LOCAL oReportViewer AS ReportViewer
    LOCAL cReportName   AS STRING
    LOCAL unit_num      AS ReportParameter
    LOCAL sDate         AS ReportParameter
    LOCAL eDate         AS ReportParameter
    LOCAL oParameter    AS ReportParameter[]
    LOCAL dDate         AS DateTime
    LOCAL oDataObject   AS Reports
    LOCAL oDS           AS ReportDataSource
    LOCAL table         AS DataTable
 
    // set up report parameters
    cReportName         := "Daily Cash.rdl"
    dDate               := DateTime.Parse(cDate)
    oDataObject         := Reports{}
    oDataObject:UserID  := goSysInfo:UserID    
    table               := oDataObject:GetMonthlySummary(nUnitKey,dDate,dDate)
    oDS                 := ReportDataSource{"SFMSales",table}
    unit_num            := ReportParameter{"unit_num", nUnitKey:ToString()}
    sDate               := ReportParameter{"startDate", dDate:ToShortDateString()}
    eDate               := ReportParameter{"endDate", dDate:ToShortDateString()}
    oParameter          := ReportParameter[]{3}
    oParameter[0]       := unit_num
    oParameter[1]       := sDate
    oParameter[2]       := eDate    
 
    // configure the reportviewer
    oReportViewer                        := SELF:ReportViewer1
    oReportViewer:ProcessingMode         := ProcessingMode.Local
    oReportViewer:LocalReport:ReportPath := cReportName
    oReportViewer:ShowParameterPrompts   := FALSE
    oReportViewer:LocalReport:SetParameters(oParameter)
    oReportViewer:LocalReport:DataSources:Add(oDS)
    oReportViewer:LocalReport:SubreportProcessing += 
           SubreportProcessingEventHandler{SELF,@SubReportEventHandler()}
    oReportViewer:LocalReport:Refresh()        
    RETURN
// ******************************************************************            
METHOD SubReportEventHandler(sender AS OBJECT, 
       e AS SubreportProcessingEventArgs) AS VOID
    LOCAL oDS   AS ReportDataSource
    LOCAL table AS datatable
    // fill table here with the appropriate data
    oDS                 := ReportDataSource{"SFMSales",Table}
    e:DataSources:Add(oDS)
    RETURN
// ******************************************************************            
END CLASS

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Willie Moore
Network Administrator AT&T
United States United States
Willie Moore is a ”Professional IT – Network Design” for AT&T located in Birmingham, Alabama. He is also the owner of wmConsulting. He has been programming in Clipper since Summer ’87 and has been producing applications in Visual Objects, Vulcan.net, PHP, VB.net, and C# for the past 20 years He is a Microsoft Certified Systems Engineer and a Microsoft Certified Trainer. Willie can be reached on the Internet at williem@wmConsulting.com.

Comments and Discussions

 
GeneralMy vote of 5 PinmemberAssil12-Jul-12 5:16 
GeneralNeed to know how to display if I have 2 or more subreports. ... Pinmemberben ong8-Nov-11 18:38 
GeneralRe: When you are in the SubReportEventHandler event, look at e.R... PinmemberWillie Moore9-Nov-11 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 13 Nov 2011
Article Copyright 2011 by Willie Moore
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid