Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1830
  • Last Modified:

ASP.NET Session Data/Array?

Hello,

How would I achieve this:

"SELECT Names from SomeTable" populates a 1-d array called CustomerNames

That array remains even though the user changes pages etc... Its pretty much a constant (as to put it) I need this list accessible from all over the app. I just want to minimize on SQL calls.

Is this possible? I dont want to have to run that SQL statement every time I need the list (elsewhere int eh app) I jsut want it to run once and be publically available
0
pegasys
Asked:
pegasys
  • 2
1 Solution
 
Bob LearnedCommented:
Store any variable in a session variable:

VB.NET

Set variable:
   Session("CustomerNames") = CustomerNames;

Get variable:
   CustomerNames = Session("CustomerNames")

Bob
0
 
pegasysAuthor Commented:
are sessionvariables datatype-less or do they assume the data-type of the content?
0
 
Bob LearnedCommented:
Session variables are type=object, and can accept anything, so you need to cast the return type into a specific variable type to access its properties.

Bob
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now