Datasets and Sessions

T

tshad

I have a Datatable that I have moved to my session variable
(session("JobBoards") = ds) where ds is my DataSet.

I have the Dataset defined in my function so I assume the dataset will be
disposed of when I leave the function. But it appears that in my above
session statement the Dataset is not in the session variable but a pointer
to my function. This may not be the case but seems to be based on the
results. But what happens after the function is exited - is the pointer
null?

session("JobBoards") = ds
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
trace.warn("Row Number " & i & ": AccountNumber = " &
ds.Tables(0).Rows(i)("AccountNumber") & " Duration = " &
ds.Tables(0).Rows(i)("Duration"))
session("JobBoards").Tables(0).Rows(i)("AccountNumber") = 150 + i
next
trace.warn("After setting session variables")
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
trace.warn("Row Number " & i & ": AccountNumber = " &
ds.Tables(0).Rows(i)("AccountNumber") & " Duration = " &
ds.Tables(0).Rows(i)("Duration"))
next
trace.warn("After setting session variables session('JobBoards')")
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
trace.warn("Row Number " & i & ": AccountNumber = " &
session("JobBoards").Tables(0).Rows(i)("AccountNumber") & " Duration = " &
session("JobBoards").Tables(0).Rows(i)("Duration"))
next

In the above set of statements, I am setting the "AccountNumber" to 150 plus
my counter. But when I display both the dataset (ds) and the session
dataset (session('JobBoards')) I see the changes. I would have expected
the session dataset to show the changes but not the original.

Here are the results:

Row Number 0: AccountNumber = 2323 Duration = 30
Row Number 1: AccountNumber = Duration = 60
Row Number 2: AccountNumber = Duration = 60

After setting session variables -- this should have the AccountNumbers
blank - I would think
Row Number 0: AccountNumber = 150 Duration = 30
Row Number 1: AccountNumber = 151 Duration = 60
Row Number 2: AccountNumber = 152 Duration = 60

After setting session variables session('JobBoards')
Row Number 0: AccountNumber = 150 Duration = 30
Row Number 1: AccountNumber = 151 Duration = 60
Row Number 2: AccountNumber = 152 Duration = 60


What am I missing?

Thanks,

Tom
 

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,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top