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 the subreport's datasource in it's collection or is there some otherway to pass data to the subreport?
Thanks,
Jon
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
Any help?
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
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 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:
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 ));
}
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 in that case the control generates meaningful diagnostics to the output windows (again, at least in localmode...)