Report Parameters collection is not populated in OnInit event when report has query dependent parameters. - by MunLeeuw

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 383212 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/20/2008 1:44:43 PM
Access Restriction Public


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.
Sign in to post a comment.
Posted by Microsoft 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
     End Try

     Dim myParam as String
     If(temp <> Nothing)
            myParam = temp
     End If
End Sub

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 In particular, please see footnote 34.
-    Additionally, please see the "Initializing Custom Assembly Objects" topic in the Books Online documentation (

SQL Reporting Services Team
Posted by MunLeeuw on 12/23/2008 at 7:20 AM
I have applied update 2 and I can still reproduce this issue.
Steve MunLeeuw
Posted by Microsoft 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
Posted by Microsoft on 12/12/2008 at 11:46 AM
Thank you for posting this issue. Your post should be reviewed the appropriate product team soon.