SQL Server Home
Report Parameters collection is not populated in OnInit event when report has query dependent parameters.
as By Design
11/20/2008 1:44:43 PM
User(s) can reproduce this bug
I use the report OnInit event to set custom assembly properties with parameter values. If the report also contains parameters that are query based, then the parameters collection is empty when the OnInit event fires. A report with the following attributes ran without warning in SQL RS 2005. The parameters that I set are language and theme, these parameters are completely unrelated to the parameter that is populated with availible values from a query. I applied SQL Cummulative update 1, but have not applied update 2, just downloaded it and will give that a try. I did not find this issue in the KB's listed.
SQL Server 2008 - Standard Edition
Win2003 Enterprise Server (SP2)
Operating System Language
Steps to Reproduce
New report (no wizard)
select 'foo' as a where 'a' = @paramDatasetInput
Create parameter named 'dependent' and set it's available values based on dataset1
Create another parameter named 'independentParameter'
all parameters accept all other default settings.
In the code for the report type in the following:
Protected Overrides Sub OnInit()
Dim foo As String
foo = Report.Parameters!independentParam.Value
Switch to preview tab, or publish the report and run it.
I have the rdl, can I upload it?
An error occurred while executing OnInit: The expression referenced a non-existing parameter in the report parameters collection. (rsErrorInOnInit)
expected the report to render
to post a comment.
Please enter a comment.
on 1/15/2009 at 2:25 PM
Thanks for reporting this issue. After reviewing the code, specs, and documentation, we have resolved this issue as By Design. Per both the RDL spec and Books Online documentation, the Parameters collection may not be referenced from the OnInit method during parameter initialization (see links below). This restriction wasn't strictly enforced in RS 2005 so parameters which did not use expressions or data sets and appeared first in the list of Report Parameters could be referenced. This behavior was inconsistent and would be extremely difficult to replicate in the RS 2008 engine.
Unfortunately, RS doesn't currently provide a way of detecting whether OnInit is called for parameter initialization or for body initialization. However, we can suggest a workaround that should allow your report to work in RS 2008. Try modifying your OnInit code along the following pattern:
Protected Overrides Sub OnInit()
Dim temp As String
temp = Report.Parameters!independentParam.Value
Catch ex As Exception
Dim myParam as String
If(temp <> Nothing)
myParam = temp
We are considering changes for a future release which would make it easier to distinguish between parameter initialization and body initialization. However, we don't have definite plans at this point.
Documentation Pointers Regarding OnInit Behavior:
- Please see "Restrictions on Use of Global Collections" on page 100 of http://download.microsoft.com/download/c/2/0/c2091a26-d7bf-4464-8535-dbc31fb45d3c/rdlNov05.pdf. In particular, please see footnote 34.
- Additionally, please see the "Initializing Custom Assembly Objects" topic in the Books Online documentation (http://msdn.microsoft.com/en-us/library/ms152801(SQL.90).aspx)
SQL Reporting Services Team
on 12/23/2008 at 7:20 AM
I have applied update 2 and I can still reproduce this issue.
on 12/22/2008 at 3:10 PM
thank you for reporting this problem. We apologize for the delay in the initial response, which happened due to a miscategorization of this issue in our tracking system. We will investigate if a workaround for this issue is possible and get back to you.
Reporting Services Team
on 12/12/2008 at 11:46 AM
Thank you for posting this issue. Your post should be reviewed the appropriate product team soon.
to post a workaround.
Please enter a workaround.
© 2014 Microsoft