472,789 Members | 1,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

Storing an array to a Session

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.
Dec 22 '05 #1
3 2274
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.

"Brad" <Br**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
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.

Dec 22 '05 #2
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.

"Brad" <Br**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
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.

Dec 22 '05 #3
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.

"Roger Twomey" wrote:
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.

"Brad" <Br**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
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.


Dec 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an...
4
by: mechweb | last post by:
Hi all, I can successfully store an array in a session variable like so: string arr1 = new string; Session = arr1; But, when I try to display the elements (using the code below) on another...
2
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to...
10
by: Mark Rae | last post by:
Hi, This relates to the previous thread "Disappearing Sessions", but is a bit more generic so I thought I'd start a new thread. This one relates to the storing of objects in Session once only to...
0
by: toton | last post by:
Hi, I have a little design related problem, and finding a good way to resolve it. To state the problem, I have points from writing of several documents. Each document represents a Session class ,...
1
by: None | last post by:
Hi, I have developed webshop application using asp.net 1.1. I'm using DataGrid in one of the pages of my site. During the page load the DataGrid will be binded by around 7500 products(rows). At...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
6
by: J055 | last post by:
Hi I have the following code. I upload an XML file using the FileUpload object, store the stream in a session so the user gets the chance to confirm some options then pass the stream from the...
3
by: Astha | last post by:
Hello ..I am new to asp.net .I have this problem of storing session values in a variable as an array.That is ..an array should contain the session values.How am i to do this in C#?and how can I...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.