all groups > sql server reporting services > february 2007 >
You're in the

sql server reporting services

group:

Static and Public/Friend Shared Vars and Hashtable


Static and Public/Friend Shared Vars and Hashtable Henry99
2/27/2007 10:48:23 PM
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



RE: Static and Public/Friend Shared Vars and Hashtable weilu NO[at]SPAM online.microsoft.com
2/28/2007 12:00:00 AM
Hello Henry,

From your description, I understand your main concern is that the Public
Variables in the Embedded code could not show in the all scope. If I
misunderstood your concern, please feel free to let me know.

Currently, I still need some time to perform research on this issue. I
appreciate your patience.

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
RE: Static and Public/Friend Shared Vars and Hashtable Henry99
2/28/2007 6:40:25 AM
Questions:
- is there any MS literature describing the behavior of Public/Friend Shared
and Static Variables in Reporting Services or do I have to test hours and
hours to see what happens?
- what could be the pattern to program a Public Shared/UserID hashtable (I
found the idea for this concept on Chris Hays' blog
http://blogs.msdn.com/chrishays/ )
RE: Static and Public/Friend Shared Vars and Hashtable weilu NO[at]SPAM online.microsoft.com
3/1/2007 12:00:00 AM
Hello Henry,

I am discussing this issue in the internal team. I appreciate your patience.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Static and Public/Friend Shared Vars and Hashtable weilu NO[at]SPAM online.microsoft.com
3/5/2007 12:00:00 AM
Hello Henry,

I got the following answer from Chris:

"
Processing order is not currently defined. It may vary from report to
report and from version to version based on performance optimizations in
the report server. There have been a few requests for the ability to put
reporting services in a mode where processing order is defined (potentially
at the cost of of some performance), so this is on our wishlist for some
future version.

The public shared variables you define are of global scope. In fact,
they're shared across sessions, so their use is highly discouraged.
However, you may be able to utilize them by hashing values based on user
id, as long as you don't have situations where the same user runs the same
report more than once at the same time.

Currently, I believe the headers and footers are normally evaluated before
the details are evaluated. As I mentioned before, this is not guaranteed
and may change from version to version or if you change the structure of
your report in such a way that triggers an optimization.

"
Hope this answered your question.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Static and Public/Friend Shared Vars and Hashtable Henry99
3/5/2007 9:06:52 AM
Thank you Wei Lu, that's a big step forward.

But one question is not answered:

What is the difference in Scope between
- Public Shared
- Friend Shared??
Public Shared may be read from other sessions, ok.
And Friend Shared ALSO or NOT?
Where ends the scope of Friend Shared?

That is really important, because we don't want to introduce UserIDs.
RE: Static and Public/Friend Shared Vars and Hashtable weilu NO[at]SPAM online.microsoft.com
3/6/2007 7:39:14 AM
Hello Henry,

The Friend Shared is Assembly Internal. Since all the session to get the
report will read the same assembly, there seems no difference between
Public and Friend Shared in this case.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Static and Public/Friend Shared Vars and Hashtable weilu NO[at]SPAM online.microsoft.com
3/8/2007 12:00:00 AM
Hello Henry,

There is some comments from Chris:

"
We'd need an architectural change on our end (e.g. running each report in
its own app domain) in order to keep shared variables from being shared
across report executions. It is likely that any such change would have
unfortunate performance implications, so we have no immediate plans to do
this.
"

If you still have any question, please feel free to let me know.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Static and Public/Friend Shared Vars and Hashtable weilu NO[at]SPAM online.microsoft.com
3/12/2007 12:00:00 AM
Hi Henry,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button