session variables and arrays

P

please-answer-here

I want to store a bunch of textstrings (about 500) returned from a database
query in a session array. I've googled all over the net, not to find any
working method.

Is there anybody who has the ultimative, definite working method as to how
you transfer a "local" array to a session array and later transfer the
session array to a "local" array.

regards
Henning
 
M

Mark J. McGinty

please-answer-here said:
I want to store a bunch of textstrings (about 500) returned from a database
query in a session array. I've googled all over the net, not to find any
working method.

Is there anybody who has the ultimative, definite working method as to how
you transfer a "local" array to a session array and later transfer the
session array to a "local" array.

Simply assign it.

Dim MyArray(500, 10)
Session("MyArray") = MyArray

The only caveat is that you must assign it from the session to a local
variable before attempting to reference any of it's elements

Dim MyArray, ele
MyArray = Session("MyArray")
ele = MyArray(1, 1)

You cannot reference elements in the session object directly:

Dim ele
ele = Session("MyArray")(1, 1) ' does NOT work


-Mark
 
P

please-answer-here

Mark said:
Simply assign it.

Dim MyArray(500, 10)
Session("MyArray") = MyArray

The only caveat is that you must assign it from the session to a local
variable before attempting to reference any of it's elements

Dim MyArray, ele
MyArray = Session("MyArray")
ele = MyArray(1, 1)

You cannot reference elements in the session object directly:

Dim ele
ele = Session("MyArray")(1, 1) ' does NOT work

Yes that was exactly what I found out, but in my case it didn't work (got
all sorts of errormessages type mismatch / index out of range) Will take a
closer look at my own code

thanks for the assistance !
 
E

Egbert Nierop \(MVP for IIS\)

Also use the following functions since variables are Empty by default

If IsEmpty(myvar) Then....

or
If IsArray(myvar) Then
Redim blah(20)
Session("myvar") = blah
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top