开发者

How do you get a subreport to render in SSRS?

开发者 https://www.devze.com 2023-01-04 18:29 出处:网络
I am wondering if someone can let me know which of the following steps I am doing wrong. Have a blank new report (\'Blank\')

I am wondering if someone can let me know which of the following steps I am doing wrong.

  1. Have a blank new report ('Blank')
  2. Have an existing report ('Sub1') which has its own data sources and one parameter (int, named 'Likelihood', with a default value). These are in the same project and same folder.
  3. Drag the subreport control onto the new report
  4. In the subreport control properties, select "Sub1" as the "Use this report as a subreport".
  5. In the parameters tab click Add.
  6. Try and select a name from the dropdown (it's empty).
  7. Enter 'Likelihood' as the name.
  8. Enter '1' as the value.
  9. Try and preview the report, get 'Error: Subreport could not be shown.' in the preview and 'rsErrorExecutingSubreport] An error occurred while executing the subreport 'SubReport1' (Instance: 0): Object reference not set to an instance of an object.' in the Output (where 'Subreport1' is the name of the control attempting to render the report 'Sub1'.

Things I have tried:

  1. Entering '=1' as the value.
  2. Adding a parameter of the same type and name to my main report 'Blank'. Leaving Parameters tab blank in subreport control properties. Also tried setting the value of a 'Likelihood' entry to be equal to the parameter on the Blank report ('=Parameters!Likelihood.Value').
  3. Setting the name as '@Likelihood' (error about req开发者_如何转开发uiring name be CLR compliant).
  4. Copying the datasources and tables etc. from the subreport to the blank parent report.

The SubReport control rdl:

<Subreport Name="Subreport1">
    <ReportName>Sub1</ReportName>
    <Parameters>
      <Parameter Name="Likelihood">
        <Value>10</Value>
      </Parameter>
    </Parameters>
    <Top>2cm</Top>
    <Left>2cm</Left>
    <Height>7cm</Height>
    <Width>7cm</Width>
    <ZIndex>1</ZIndex>
    <Style>
      <Border>
        <Style>None</Style>
      </Border>
    </Style>
  </Subreport>

I have encountered many others with similar problems but I have not yet found a solution and would appreciate a point in the right direction.


I came across a forum on ActiveReports6 where an identical error was being encountered. In that case, the user (DeepSeaDave), "put a breakpoint in the subreport's DataSourceChanged() event. When [he called] the main report's Run() method, the DataSourceChanged event [fired] twice. The second time it [fired was] when the datasource [became] Nothing..."

I encountered the same problem (also involving a sub-report, and also involving Shared Data Sources), after I had copied/renamed an existing report (as well as the sub-report) as the template for a new one.

Solution:

By deleting the Data Source (report specific link to the Shared Datasource in the Project) in my parent report, and re-creating it (saving and closing down in between), the problem went away!


I realised I'm using a shared dataset on my subreport and others have encountered that issue. I deleted everything in my subreport, but it wasn't until I deleted that dataset that it would render without an error (i.e. a blank page as expected since I deleted everything). With this in mind I played with some settings and come up with the "solution" below.

One "solution" that "worked" for me was:

  1. Set the dataset to be non-shared, save, preview (to force the "recache" or whatever).
  2. Add an equivalent non-shared dataset on the parent report. Try previewing.
  3. Undo your original subreport changes (I literally did a source control undo)
  4. Make sure you can still preview your subreport.
  5. Delete the dataset on the parent report.
  6. It's magically working.

I wish I knew what caused this to start working again and I fully expect it will break again, but I do know that this is what I did and now it works so maybe its a cached reports issue?

This is NOT a solution, but I would be very interested to hear if it helps anyone else as maybe it will help us isolate the issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号