|
My main report has a subreport that has a table in it with an associated dataset. When I run the report, the main data displays, but the area that is supposed to show the subreport shows "subreport could not be shown". If I remove the table and dataset from the subreport, the headings will display. But as soon as I add the table and dataset back I get the error. I am setting the dataset for the main report and subreport before running the report. Does anyone have any suggestions? Thanks.
|
| Roman Benko Friday, July 29, 2005 9:24 PM |
You can get this error if ReportViewer could not find the .rdlc file for the subreport, or if you didn't supply a parameter required by the subreport, or if data expected by the subreport was not supplied. To supply data to the subreport you have to handle the SubreportProcessing event. |
| Rajeev Karunakaran Tuesday, August 02, 2005 2:11 AM |
This is what I was able to do in case anyone needs this someday. I simply put an expression on the subreport1 object of my mainreport in it's Hidden attribute that tested if a field on the subreport was nothing then true. In other words, hide the subreport if there is no data on it. It worked beautifully!!
Here is the code I put in the Visibility - Hidden attribute of the subreport object:
=iif (First(Fields!PDNO_ITEM.Value) is Nothing,True, False)
the field PDNO_ITEM being on the subreport.
Very cool.
|
| NikkiZ Friday, September 14, 2007 7:43 PM |
You can get this error if ReportViewer could not find the .rdlc file for the subreport, or if you didn't supply a parameter required by the subreport, or if data expected by the subreport was not supplied. To supply data to the subreport you have to handle the SubreportProcessing event. |
| Rajeev Karunakaran Tuesday, August 02, 2005 2:11 AM |
Can anyone provide a little more detail. I've checked that the subreport parameters are beging passed.
I'm not sure what "if data expected by the subreport was not supplied" means. Does the master report need to have thesubreport's datasource in it's collection or is there some otherway to pass data to the subreport?
Thanks, Jon |
| JonathanEdwards Monday, March 20, 2006 9:41 PM |
Hi,
I am developing an asp.net web application which accesses Reports created using SQL Server 2005 reporting Services using a Report Viewer. These reports are located on a Report server. Some of these reports also have sub reports in them. Now the problem is that when I try to view Reports having Sub Reports, the main report is displayed correctly. However an error message is displayed in the area where the sub report is to be displayed. All the required parameters are passed correctly and the application runs perfectly through visual studio. However, when I try to use this application through the portal, I face this problem.
Any help is appreciated.
Thanks in advance,
Mahesh C
|
| maheshci Friday, January 19, 2007 11:18 AM |
I get the same problem too. Works fine in the environment/local mode, also works fine when I deploy to our Development server. However, when I deploy to the Production server, I get the problem?
Any help?
|
| KChampion Wednesday, April 11, 2007 5:57 PM |
I've gotten this problem if the description I put into Report Services doesn't exactly match the file name of the sub report. I can use any description I want for the main report, but the sub-report has to mirror the file name (minus the .rdl). I've also had this problem if the sub-report had spaces in the name, replace all spaces with underscores and everything worked well for me after deleting and re-uploading the report (the update and overwrite doesn't seem to work very well).
Hope that Helps,
Dave |
| ShadowLord Monday, June 25, 2007 2:59 PM |
| Roman Benko. wrote: |
My main report has a subreport that has a table in it with an associated dataset. When I run the report, the main data displays, but the area that is supposed to show the subreport shows "subreport could not be shown". If I remove the table and dataset from the subreport, the headings will display. But as soon as I add the table and dataset back I get the error. I am setting the dataset for the main report and subreport before running the report. Does anyone have any suggestions? Thanks.
| | I have the same problem . Pleasehelpmeivan_pie@ukr.net |
| P.I_ Thursday, August 02, 2007 10:09 AM |
I had the same problem: single subreport that requires one dataset and no parameters. I've managed to solve the problem by explicitly calling LoadSubreportDefinition. The code for my ASP.NET page follows:
Code Snippet
protected override void OnLoad( EventArgs e ) {
base.OnLoad( e );
using( System.IO.Stream report = System.IO.File.OpenRead( Server.MapPath( "~/Report2.rdlc") )){
this.ReportViewer1.LocalReport.LoadSubreportDefinition( "Report2", report );
}
this.ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler( LocalReport_SubreportProcessing );
this.ReportViewer1.LocalReport.Refresh();
}
void LocalReport_SubreportProcessing( object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e ) {
e.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource( "SubreportDataSet", this.SqlDataSource1 ));
}
|
| Perobas Monday, August 20, 2007 2:46 PM |
A subreports' dataset is not automatically filled, nor is it automatically added to the subreports Datasources.
In the case of the person reporting that the subreport displays without the dataset but will not display with the dataset specified, it's pretty clear that the dataset is the issue.
First of all, make sure the dataset is sound. For example, verify that you're not specifying a SQL query that will generate exceptions and that is returning valid data.
Second of all, I've found that I often need to set EnforceConstraints to false on my datasets, or the automagically-generated (xsd/cs) dataset code will throw.
Third, make sure you have implemented the SubreportProcessing event and that your event handler is templated off one of the many examples floating around. There's a reason 90%+ of those event handlers look so much alike.
Also make sure that any/all field specifications in subreport are correct. If not, the rv control will error out attempting to render the subreport when it can't find the field as specified in the dataset provided.
Finally, run your report under debug and watch the output window. The reportviewer control generates few other diagnostics, but in cases where rendering/display fails it will often generate meaningful diagnostics into the output window (at least in localmode, I don't work with the web version.)
Subreport processing can conceptually fail for a great many reasons, but in my experience there's really only a few classes of failures that cover most cases.
If you're using Parameters and the pluming isn't correct, that will cause a subreport to fail. But inthat case the control generates meaningful diagnostics to the output windows (again, at least in localmode...) |
| eldelo Tuesday, August 21, 2007 6:16 PM |
I'm using SQL reporting services with a very simple report andsubreport. All is working well and as expected. My question is - there are sometimes when the subreport is displaying Error: subreport can not be shown. This is totally correct - sometimes there won't be anything to return based on my parameter but I'm wondering can I test for that error and somehow display nothing instead of the error. I thought about laying a blank rectangle over the subreport and displaying it if the error was there. Is this possible?? am I making any sense??
Thanks - Nikkiz |
| NikkiZ Friday, September 14, 2007 3:29 PM |
In some of our reports we use subreports as headers (not ReportViewer headers, but logical headers) of sorts - to display summary information.
The information is contained in the the first row of the dataset that the subreport consumes.
We found that when the dataset is empty (has no rows at all) or had nonsensical/bad data relative to what the fields expect, we'd see what you're reporting.
This is strictly anecdotal as I'm not claiming to know what the subreport's behavior is intended to be or ought to be in such cases, but that's what we observed.
We worked around it by writing a routine that adds a row to the dataset (if none are present) and, after adding that first row if necessary, fixes up the data.
|
| eldelo Friday, September 14, 2007 4:01 PM |
This is what I was able to do in case anyone needs this someday. I simply put an expression on the subreport1 object of my mainreport in it's Hidden attribute that tested if a field on the subreport was nothing then true. In other words, hide the subreport if there is no data on it. It worked beautifully!!
Here is the code I put in the Visibility - Hidden attribute of the subreport object:
=iif (First(Fields!PDNO_ITEM.Value) is Nothing,True, False)
the field PDNO_ITEM being on the subreport.
Very cool.
|
| NikkiZ Friday, September 14, 2007 7:43 PM |
I have a report with a subreport in it. The .rdlc file for the subreport has been defined. There is yet no report parameter upon which would define the subreport's dependency on the mainreport to keep it simple. I am not certain as to the content which i would place in the code area. By researching upon similar scenarios, I understand that I should include a SubreportProcessingEvent. My code looks like this:
Option Explicit On Imports System Imports System.Drawing Imports Microsoft.Reporting.WinForms
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim instance As LocalReport = Me.ReportViewer1.LocalReport AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf Me.SubreportProcessingEventHandler
Me.spInfoGetTableAdapter.Fill(Me.TimesheetDataSet1.spInfoGet)
Me.ReportViewer1.RefreshReport()
End Sub
Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
Me.spGetTableAdapter.Fill(Me.TimesheetDataSet.spGet, 0)
End Sub
End Class
As I've understood it, the dataset for the mainreport will be populated separately from that of the subreport. The SubreportProcessingEventHandler takes care of populating the dataset for the subreport. Did i understand it correctly? Upon debugging, my mainreport was displayed correctly. However, an 'Error: Subreport can not be shown.' was displayed in my subreport.
Anyone please help me understand this and fix my current problem. I am an amateur on this thing. Any suggestions is greatly appreciated. Thanks.
-mcpg
|
| mcpg Monday, September 17, 2007 1:20 AM |
I have searched far and wide for answers and nothing seems to fit my scenario exactly. Like a few out there I am using business objects as my data sources. I have a detail record that populates textboxes fine, but upon loading the initial report, I also want a subreport to load with a collection of comments for the aformentioned detail record. I get the static text from the subreport to appear, but the comments are not populated, so I assume that the connection between the table and the datasource is broken. Please see my code below and tell me what I may be doing wrong.
Public Sub SubreportProcessingEventHandler(ByVal sender As Object, _ ByVal e As SubreportProcessingEventArgs) Try
Dim mySubreportBindingSource As New BindingSource e.DataSources.Add(New ReportDataSource("Comments", mySubreportBindingSource)) mySubreportBindingSource.DataSource = Comments
Catch ex As Exception Throw New Exception(ex.ToString) End Try
|
| sushi1584 Monday, September 17, 2007 11:18 PM |
I have solved my own problem! In the code below, combined two lines of code, and I needed to go one level deeper to the items property, which is my list(of comments), of the collection class:
e.DataSources.Add(New ReportDataSource("Comments", mySubreportBindingSource)) + mySubreportBindingSource.DataSource = Comments
= e.DataSources.Add(New ReportDataSource("Comments", Comments.Items)
|
| sushi1584 Tuesday, September 18, 2007 7:11 PM |
I get exactly the same problem.I tested thereport through the report server.
It works on dev, but when I test on production it fails.
Is therehelp for this? |
| OConnor Wednesday, September 19, 2007 5:30 PM |
There are a number of things suggested here http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1832636&SiteID=1-- in the end El Delo fixed his problem by making sure that the prod machine was patched...
>L< |
| Lisa Nicholls Thursday, September 20, 2007 12:54 PM |
I too had this problem. And I resolved it by adding parent datasource also in the event.
Here is the details.
I had one main report and one sub report.
While loading, I added
ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
and in this event, along with adding ObjectDataSource2 (for subreport)I also added ObjectDataSource1 (which was actually for main report). The problem was solved for me.
e.DataSources.Add( new Microsoft.Reporting.WebForms.ReportDataSource("DataSet2_TimeRecord","ObjectDataSource2"));
e.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_TimeRecord", "ObjectDataSource1"));
Happy coding |
| GotFocus Thursday, March 13, 2008 6:09 PM |
I just experienced the same (or simliar) thing. I had a report with 3 sub reports working fine. I moved all of the reports (4 in total) to different folders and had to re-link the sub reports to the main report... after doing that... my 3rd sub report didn't show up. I had to remove it (the 3rd sub report) from the main reportand then add in a new sub report in it's place which pointed to the same report as the one I removed. It works... but WTF...?? I sure hope MS iscollecting this kind of data off the forums... cause that's what will keep us posting about weird things like this that seem to come up on a daily basis... at least for me. --
Tyler Mitton
http://www.rippleaudio.com
__________________________________
Need Background Music?
Buy & Sell Audio @ http://www.rippleaudio.com |
| Tyler Mitton Friday, February 13, 2009 4:33 PM |
Another situation that can cause this error is if you reference custom library methods and forget to set the references and / or classes on the references tab for the sub report. |
| j2associates Tuesday, August 11, 2009 7:50 PM |
After a Loooooong .. long troubleshooting... My problem and solution was as following. The probem was that ONLY in some cases the Subreport shows the "Error: Subreport could not be shown" The sulution for be was that one of parameters to the Subreport was:
=Fields!CalcGroupId.Value
The works fine in 95% of cases but not the last 5%. Then i changed it to this:
=First(Fields!CalcGroupId.Value, "dataset")
and now it works. There is still a red underline in the editor that says: "unknown collection member" ... But it must be a microsoft bug... becase it works. Cheers
Jan Borup Coyle |
| Jan Borup Coyle Friday, October 02, 2009 12:11 PM |