sql server reporting services:
We need to live with Global Variables in user code (embedded in the RDL)
Question 1: What is the scope difference between Public Shared and Friend
Shared?
A MS oficial (forgot who, he was on the Reporting Services Team Member
Blogs: one of Bob, Brian, Chris, Lukasz, Tudor) wrote in his blog, that for
avoiding concurrency we should make a shared variable hash table based on
user ID
Question 2: How may I accomplish that?
Question 3: After introducing these User IDs, what then about Report
Subscriptions (and other unattended tasks)? They'll not work anymore?
When I use Static Variables in a user code Function, they work correctly
during rendering of the body. Then, when rendering the header, their count
begins from zero and is continued during rendering of the footer.
Question 4: How can I introduce static variables that have an overall scope?
Making tests with variables I noted, that setting and interpreting of
public/friend shared vars is different while:
- rendering for normal view in ReportViewer Control the sequence is
Body/Header/Footer
- performing Print Preview or Export to PDF the sequence seems to be
Body/Footer/Header
Question 5: Where do I get more information about Reporting Services
architecture to understand Variable treatment and Render sequence during
normal view, print preview, export to PDF etc.?
------------------------------
user code to test functionality:
'directly accessible via =code.psVar from: body, header, footer
Public Shared psVar As String = "psVarInit"
'directly accessible via =code.fsVar from: body, header, footer
Friend Shared fsVar As String = "fsVarInit"
'directly accessible via =code.pVar from: body, header, footer
Public pVar As String = "pVarInit"
'following Var is automatically private to this code
'has to be accessed via set/get-functions below
Dim Var As String = "VarInit"
'not valid here: Static Dim stStatic As Integer = 0
'Public Static Dim stpStatic As Integer = 0
'Public Shared stpsStatic Dim stpStatic As Integer = 0
Function setpsVar(ByVal value As String) As String
psVar = value
End Function
Function setfsVar(ByVal value As String) As String
fsVar = value
End Function
Function setpVar(ByVal value As String) As String
pVar = value
End Function
Function setVar(ByVal value As String) As String
Var = value
End Function
Function getVar() As String
Return Var
End Function
Public Function getStatic() As String
Static Dim strStatic As Integer = 0
strStatic += 1
Return strStatic
End Function