Sub report could not be shown. Sub report works separately - Not with Main Report

30,769

Solution 1

I believe you've actually already found the cause of your problem.

I've also checked this, nut no success

The post you're refering to has the following accepted answer by lethaljd:

This is a known defect in SSRS 2008. I'm not sure if it has been patched yet, but it has been fixed in SSRS 2012.

As you have found, the workaround is to use separate datasets.

https://connect.microsoft.com/SQLServer/feedback/details/648560/subreport-with-shared-dataset-throws-error

If you check the source that lethaljd has provided, it shows that this hasn't been patched either and probably never will be as it is no longer an issue in the newer versions.

This means that you should probably use a newer version of SSRS or think of a workaround. I'd like to help you think of a different approach but as I've stated in my original comment, you'll need to give a lot more information.
As the question is written now, I do not posses enough details to give you any well founded advice other than using a different version.

That being said, I do not wish this answer to come over as nonconstructive or negative. I just merely want to help you on the right track.

Solution 2

Apart from checking the obvious steps as above... (Some might say this is obvious too...) I had to make sure that the parameters' datatypes (in the subreport) matched the columns they match in the main report.

When you have done that and you are still getting an error...

I am assuming you are using VStudio like I am. This is how I clean out the VStudio cache...

Unload the Report Close VStudio Go to the report folder in WinExplorer. Backup the solution folder Now go to the Project folder underneath the Solution folder Notice there are 3 types of files: - .rdl <-- This contains the Report definition... Don't touch this... - .rdl.data <-- Contains the cached data for the report executuion - .rds <-- This is your datasource definition... No need to touch it - .rptproj <-- This contains your project definitions... Don't touch it - .rptproj.user <-- Do not touch this... It contains the credentials for your data source Then you have a bin folder with 3 sub-folders... Debug, Release, and Debuglocal

Here is what you do: Remove all the .rdl.data files Remove all files under bin/Debug/* and repeat for DebugLocal and Release.

This should clean up the VStudio environment. Now open the solution... Reload the solution in VStudio and try again.

This fixed a number of these pesky data cache issues.

Solution 3

You should check this:

  • multiple parameters must be defined as multivalue on main report and on subreport (define on subreport to allow multiple values)
  • when you passing multiple parameter to subreport you should pass it like [@param] and not like =Parameters!ParamName.Value(0)

On this blog is explained how to send multiple values to subreport.

Solution 4

I've just had the same error, (though I'm not using multi valued parameters) I've added 2 new parameters to the subreport and set the parameter values in the main report.

It turned out to be the parameters in the subreport! My 2 new parameters are for datetime but when these were created by the wizard they were set as Text, once changed to Date/Time everything is working fine.

Share:
30,769
Pedram
Author by

Pedram

#SOreadytohelp C#.Net, VB.Net, ASP.NET, SQL SERVER, GitHub Actions, SonarQube, CICD

Updated on August 07, 2021

Comments

  • Pedram
    Pedram over 2 years

    I've one main report with 5 sub reports.

    Sub report contains more than 10 parameters. (With 10 Multi valued parameters - So I've used Join method to pass value from Main report to Sub Report)

    I've also tested Sub report separately and it is all working fine, showing data and everything.

    I've tried by making another main report and tried to put that sub report in this newly created main Report but still no success.

    I've also checked each and every parameter values and datatypes all are correct as per my store procedure.

    I've tried by removing multivalued parameter one by one from Sub report properties to check weather issue is due to this multivalued parameter or what!

    When we supply value from main report to sub reprot by using sub report properties - here when I clicked multivalued parameter it comes up with

    =Parameters!ParameterName.Value(0) -- (0)

    So it is okay or not? As I'm using it as multi selected values.

    I'm stuck with this issue and I'm getting below error,

    Error: Subreport could not be shown.

    Any help please, Thanks in advance.

    Please Note:

    I've checked this, but No success

    I've also checked this, but No success

    Getting below error on main Report page,

    enter image description here

    I've also tried by uploading the all reports on SSRS-2012 but no success.

  • Pedram
    Pedram over 8 years
    I've tried everything, even reports uploaded on SSRS 2012 - issue is still there. And the other thing is that, I am converting all the crystal reports to ssrs reports - and I must need to pass all the parameter's value by query-string. Thanks for the help.
  • Oceans
    Oceans over 8 years
    A few days ago you commented that you would edit your question and add more details. I see you've removed that comment but you still haven't added the necessary information for me to help you further. - Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example.
  • Pedram
    Pedram over 8 years
    I've already checked your first point, about second point - when you set parameter value it will show you like [@param] on UI but inside expression it will be =Parameters!ParameterName.Value(0)
  • Gane
    Gane over 8 years
    Try this: edit the expression and make sure it doesn't have a (0) at the end. =Parameters!ParamName.Value is correct, not =Parameters!ParamName.Value(0)
  • Pedram
    Pedram over 8 years
    whatever I have written in my question is what I am doing, I could not provide you more details in that, if you can't provide the help then it's fine. thank you so much for your help and time. I really appreciate it. I am also accepting that I have commented before to provide you more details but somehow it is no possible to provide you whole design, reports data and the code also. so sorry for that. :(
  • Pedram
    Pedram over 8 years
    really thanks. Today I worked on the same and issue has been fixed with changing report server. Even I've tried before by changing the report server but somehow I've not focused on one thing and that is I must need to hide all parameters in all reports Main Report as well as Sub report. Before I've not checked this things and all changes I have made by opening Edit Report Builder of SSRS 2012. It only worked with SSRS-2012 - 2008 has some issue. Thanks a lot. I'm so happy today... I'm accepting your answer as well. ;-) BTW sorry for secretive about what exactly I'am making :D Thnkz
  • Pedram
    Pedram over 8 years
    also after made changes in SSRS-2012 - I've uploaded the same report on SSRS-2008 and it is working fine now with SSRS-2008 also :)