Storing an array to a Session

G

Guest

I am storing an array which contains about a dozen chracter items to a
Session variable. Later, I need to use this array so I am doing the
following:

Dim eventTypes As String() = DirectCast(Session("EventTypes"), String())
If Date.Today <= closeDate Then
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("PEFee")
Else
If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
Session("JRFee") Else thisFee = Session("DOSFee")
End If

I have determined that the values are properly being stored into the initial
array. I then assign a session variable to store this array. When I try to
use the array in the segment above, I get the error "Object reference not set
to an instance of an object - use the "new keyword".

Obviously when I dim the eventTypes() something is wrong here. Please help.

Thanks for the information.
 
M

Marina

Either a new session is being started, or you are not retrieving the data
using the same session variable name, or something like that.

Basically, your variable references nothing after the assignment.
 
R

Roger Twomey

If you have the array in the session I would do this:

Dim EventTypes as String()
EventTypes = Session("EventTypes")

If for some reason that doesn't work just put this line in the middle to try
(I know it's nuts but try it)
Redim EventTypes(0)

Make sure that Date.Today, cblEntries.SelectedIndex and Session("PEFee")
etc. all exist. The problem might not be the array, but the message isn't
reveailing it.

I am fairly certain that I have done this in the past with no ill effects.
 
G

Guest

Thank you both for the information, but for some reason it still does not
work. However, with a lot of things, I did a work-around and I am not using
an array. I am just doing some string manipulation and comparing the string.

I still would like to get the array to work, however.

Thanks again.
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top