Click here to Skip to main content
15,880,608 members
Articles / SSRS
Tip/Trick

SSRS - Error: Subreport could not be shown

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
13 Nov 2011CPOL 42.3K   3   3
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.


C++
// 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)


Written By
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 Pin
Assil12-Jul-12 5:16
professionalAssil12-Jul-12 5:16 
GeneralNeed to know how to display if I have 2 or more subreports. ... Pin
ben ong8-Nov-11 18:38
ben ong8-Nov-11 18:38 
GeneralRe: When you are in the SubReportEventHandler event, look at e.R... Pin
Willie Moore9-Nov-11 2:56
Willie Moore9-Nov-11 2:56 

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

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