Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion to Hashtable or other

Status
Not open for further replies.

lanm

Programmer
Jul 7, 2005
244
US
Here's my code:

Shared offset As Integer

Public Function GetPN(reset As Boolean, pagenumber As Integer) As Integer
If reset
offset = pagenumber - 1
End If
Return pagenumber - offset
End Function

This is for a report page number reset on a new grouping value. Since the offset must be shared (so that this will work across multiple callbacks to the server), if more than one person runs the report at the same time they’ll smash each other. I need to modify the offset to be a hashtable, and am not sure how I would.....or if there's another possible route.

Thanks!
 
Insted of a shared variable, why not use a session variable? This way the value is persisted, but only for the current user(session).
 
Not sure where I'm going wrong, or really how to go about this, but here's what I have so far. I'm still a little new to session objects.

I'm getting:
Expression is not an array or method, and cannot have an arguement list.

Shared offset As Integer

Public Function GetPN(ByVal reset As Boolean, ByVal pagenumber As Integer) As Integer
If reset Then
offset(Session("report")) = pagenumber - 1
End If
Return pagenumber - offset
End Function

Thanks!
 
jbenson001 stated that you should use session variables instead of shared variables not as well as. e.g.
Code:
Public Function GetPN(ByVal reset As Boolean, ByVal pagenumber As Integer) As Integer
  If reset Then
      Session("report") = pagenumber - 1
  End If
  Return pagenumber - Session("report")
End Function


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks ca3msm!

I've got this for the Report Code:
Imports System.Web.SessionState

Public Function GetPN(ByVal reset As Boolean, ByVal pagenumber As Integer) As Integer
If reset Then
Session("report") = pagenumber - 1
End If
Return pagenumber - Session("report")
End Function

I get a build error saying:
There is an error on line 0 of custom code. 'Imports' statements must precede any declarations.
 
Imports have to go on the very top of the code behind page, before the page class declaration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top