Wednesday, September 9, 2009

Debugging "SubReport could not be shown."

I've been upgrading a local report which contains multiple subreports, and yes I got that "SubReport could not be shown." error more than once.

Debugging this error is a pain in the a.. All you get is "SubReport could not be shown.", making me want to punch my screen and scream "BUT WHY?"

Just before breaking my screen and going on full tilt, I decided to take a step back and run through my checklist.

Here it goes..

Can the reportviewer find the subreports?

If the subreports are in another location (other folder, other assembly..), the reportviewer will not find them.

The solution for this problem is using the LoadReportDefinition method and passing the report definition as a stream. An example can be found in this post.

Are you passing all parameters?

Doublecheck your report parameters.

Are you passing all the required/correct data to the report?

Are you handling the SubReportProcessing event, to pass the data to the subreports, not the main report?

Did the database definition change? Did a query break? Is the structure of the query still the same as defined in your report definition?

Are there other things to add to this list?

No comments:

Post a Comment