Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dataset in Session state

Reply
Thread Tools

Dataset in Session state

 
 
Vik
Guest
Posts: n/a
 
      02-04-2004
A dataset is saved in session state. Then the dataset is filled out with the
new records using a dataadapter. It appears then that the dataset saved in
session state contains the new records even without saving the updated
dataset.

Why does this happen? How can I preserve the dataset saved in session state
from automatical updating?

Thank you.


 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      02-04-2004
a code snip on how you are trying to use it would help. From my current
understanding here's what i think:

when you add objects to session they are added by value and not by
reference. ie one that you are refering to in you code is a local copy of
the object stored session.
any changes to the local copy would not be updated directly. you will need
to manually update the object in session.

--
Regards,
HD
Once a Geek.... Always a Geek
"Vik" <viktorum@==hotmail.com==> wrote in message
news:(E-Mail Removed)...
>A dataset is saved in session state. Then the dataset is filled out with
>the
> new records using a dataadapter. It appears then that the dataset saved in
> session state contains the new records even without saving the updated
> dataset.
>
> Why does this happen? How can I preserve the dataset saved in session
> state
> from automatical updating?
>
> Thank you.
>
>



 
Reply With Quote
 
 
 
 
Vik
Guest
Posts: n/a
 
      02-05-2004
Thank you Hermit. Here is my code.

SqlDataAdapter1 and DataSet11 are created in design time.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim N0, N1, N2 As Int16, Str1, Str2 As String, DS As DataSet

Session("DS") = DataSet11

N0 = DataSet11.Tables(0).Rows.Count 'N0=0

SqlDataAdapter1.Fill(DataSet11)

DS = Session("DS")

N1 = DataSet11.Tables(0).Rows.Count 'N1=3

N2 = DS.Tables(0).Rows.Count 'N2=3

Str1 = DataSet11.Tables(0).Rows(1)(1) 'Str1="Other"

Str2 = DS.Tables(0).Rows(1)(1) 'Str2="Other"

End Sub

So, the dataset is saved in session state only once when it is empty. After
the dataset is filled out its saved copy has all the new records. What I
need and expected is that the dataset in session state keeps the old records
(remains empty in this case) when the real dataset is updated.

Vik

"Hermit Dave" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> a code snip on how you are trying to use it would help. From my current
> understanding here's what i think:
>
> when you add objects to session they are added by value and not by
> reference. ie one that you are refering to in you code is a local copy of
> the object stored session.
> any changes to the local copy would not be updated directly. you will need
> to manually update the object in session.
>
> --
> Regards,
> HD
> Once a Geek.... Always a Geek
> "Vik" <viktorum@==hotmail.com==> wrote in message
> news:(E-Mail Removed)...
> >A dataset is saved in session state. Then the dataset is filled out with
> >the
> > new records using a dataadapter. It appears then that the dataset saved

in
> > session state contains the new records even without saving the updated
> > dataset.
> >
> > Why does this happen? How can I preserve the dataset saved in session
> > state
> > from automatical updating?
> >
> > Thank you.
> >
> >

>
>



 
Reply With Quote
 
Hermit Dave
Guest
Posts: n/a
 
      02-05-2004
i see what you mean now.

try using

Session("DS") = DataSet11.Copy()

that way you are explicitly saving a copy. I will have a play around with
this later on.

--
Regards,
HD
Once a Geek.... Always a Geek
"Vik" <viktorum@==hotmail.com==> wrote in message
news:%23hHYK2$(E-Mail Removed)...
> Thank you Hermit. Here is my code.
>
> SqlDataAdapter1 and DataSet11 are created in design time.
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> 'Put user code to initialize the page here
>
> Dim N0, N1, N2 As Int16, Str1, Str2 As String, DS As DataSet
>
> Session("DS") = DataSet11
>
> N0 = DataSet11.Tables(0).Rows.Count 'N0=0
>
> SqlDataAdapter1.Fill(DataSet11)
>
> DS = Session("DS")
>
> N1 = DataSet11.Tables(0).Rows.Count 'N1=3
>
> N2 = DS.Tables(0).Rows.Count 'N2=3
>
> Str1 = DataSet11.Tables(0).Rows(1)(1) 'Str1="Other"
>
> Str2 = DS.Tables(0).Rows(1)(1) 'Str2="Other"
>
> End Sub
>
> So, the dataset is saved in session state only once when it is empty.
> After
> the dataset is filled out its saved copy has all the new records. What I
> need and expected is that the dataset in session state keeps the old
> records
> (remains empty in this case) when the real dataset is updated.
>
> Vik
>
> "Hermit Dave" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> a code snip on how you are trying to use it would help. From my current
>> understanding here's what i think:
>>
>> when you add objects to session they are added by value and not by
>> reference. ie one that you are refering to in you code is a local copy of
>> the object stored session.
>> any changes to the local copy would not be updated directly. you will
>> need
>> to manually update the object in session.
>>
>> --
>> Regards,
>> HD
>> Once a Geek.... Always a Geek
>> "Vik" <viktorum@==hotmail.com==> wrote in message
>> news:(E-Mail Removed)...
>> >A dataset is saved in session state. Then the dataset is filled out with
>> >the
>> > new records using a dataadapter. It appears then that the dataset saved

> in
>> > session state contains the new records even without saving the updated
>> > dataset.
>> >
>> > Why does this happen? How can I preserve the dataset saved in session
>> > state
>> > from automatical updating?
>> >
>> > Thank you.
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Vik
Guest
Posts: n/a
 
      02-05-2004
Thank you. This works.

Vik

"Hermit Dave" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> i see what you mean now.
>
> try using
>
> Session("DS") = DataSet11.Copy()
>
> that way you are explicitly saving a copy. I will have a play around with
> this later on.
>
> --
> Regards,
> HD
> Once a Geek.... Always a Geek
> "Vik" <viktorum@==hotmail.com==> wrote in message
> news:%23hHYK2$(E-Mail Removed)...
> > Thank you Hermit. Here is my code.
> >
> > SqlDataAdapter1 and DataSet11 are created in design time.
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> >
> > 'Put user code to initialize the page here
> >
> > Dim N0, N1, N2 As Int16, Str1, Str2 As String, DS As DataSet
> >
> > Session("DS") = DataSet11
> >
> > N0 = DataSet11.Tables(0).Rows.Count 'N0=0
> >
> > SqlDataAdapter1.Fill(DataSet11)
> >
> > DS = Session("DS")
> >
> > N1 = DataSet11.Tables(0).Rows.Count 'N1=3
> >
> > N2 = DS.Tables(0).Rows.Count 'N2=3
> >
> > Str1 = DataSet11.Tables(0).Rows(1)(1) 'Str1="Other"
> >
> > Str2 = DS.Tables(0).Rows(1)(1) 'Str2="Other"
> >
> > End Sub
> >
> > So, the dataset is saved in session state only once when it is empty.
> > After
> > the dataset is filled out its saved copy has all the new records. What I
> > need and expected is that the dataset in session state keeps the old
> > records
> > (remains empty in this case) when the real dataset is updated.
> >
> > Vik
> >
> > "Hermit Dave" <(E-Mail Removed)> wrote in

message
> > news:%(E-Mail Removed)...
> >> a code snip on how you are trying to use it would help. From my current
> >> understanding here's what i think:
> >>
> >> when you add objects to session they are added by value and not by
> >> reference. ie one that you are refering to in you code is a local copy

of
> >> the object stored session.
> >> any changes to the local copy would not be updated directly. you will
> >> need
> >> to manually update the object in session.
> >>
> >> --
> >> Regards,
> >> HD
> >> Once a Geek.... Always a Geek
> >> "Vik" <viktorum@==hotmail.com==> wrote in message
> >> news:(E-Mail Removed)...
> >> >A dataset is saved in session state. Then the dataset is filled out

with
> >> >the
> >> > new records using a dataadapter. It appears then that the dataset

saved
> > in
> >> > session state contains the new records even without saving the

updated
> >> > dataset.
> >> >
> >> > Why does this happen? How can I preserve the dataset saved in session
> >> > state
> >> > from automatical updating?
> >> >
> >> > Thank you.
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Vik
Guest
Posts: n/a
 
      02-05-2004
Is it possible to release memory occupied by a Session object? E.g. will
this work: Session("DS") = Nothing ?

Vik

"Hermit Dave" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> i see what you mean now.
>
> try using
>
> Session("DS") = DataSet11.Copy()
>
> that way you are explicitly saving a copy. I will have a play around with
> this later on.
>
> --
> Regards,
> HD
> Once a Geek.... Always a Geek
> "Vik" <viktorum@==hotmail.com==> wrote in message
> news:%23hHYK2$(E-Mail Removed)...
> > Thank you Hermit. Here is my code.
> >
> > SqlDataAdapter1 and DataSet11 are created in design time.
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> >
> > 'Put user code to initialize the page here
> >
> > Dim N0, N1, N2 As Int16, Str1, Str2 As String, DS As DataSet
> >
> > Session("DS") = DataSet11
> >
> > N0 = DataSet11.Tables(0).Rows.Count 'N0=0
> >
> > SqlDataAdapter1.Fill(DataSet11)
> >
> > DS = Session("DS")
> >
> > N1 = DataSet11.Tables(0).Rows.Count 'N1=3
> >
> > N2 = DS.Tables(0).Rows.Count 'N2=3
> >
> > Str1 = DataSet11.Tables(0).Rows(1)(1) 'Str1="Other"
> >
> > Str2 = DS.Tables(0).Rows(1)(1) 'Str2="Other"
> >
> > End Sub
> >
> > So, the dataset is saved in session state only once when it is empty.
> > After
> > the dataset is filled out its saved copy has all the new records. What I
> > need and expected is that the dataset in session state keeps the old
> > records
> > (remains empty in this case) when the real dataset is updated.
> >
> > Vik
> >
> > "Hermit Dave" <(E-Mail Removed)> wrote in

message
> > news:%(E-Mail Removed)...
> >> a code snip on how you are trying to use it would help. From my current
> >> understanding here's what i think:
> >>
> >> when you add objects to session they are added by value and not by
> >> reference. ie one that you are refering to in you code is a local copy

of
> >> the object stored session.
> >> any changes to the local copy would not be updated directly. you will
> >> need
> >> to manually update the object in session.
> >>
> >> --
> >> Regards,
> >> HD
> >> Once a Geek.... Always a Geek
> >> "Vik" <viktorum@==hotmail.com==> wrote in message
> >> news:(E-Mail Removed)...
> >> >A dataset is saved in session state. Then the dataset is filled out

with
> >> >the
> >> > new records using a dataadapter. It appears then that the dataset

saved
> > in
> >> > session state contains the new records even without saving the

updated
> >> > dataset.
> >> >
> >> > Why does this happen? How can I preserve the dataset saved in session
> >> > state
> >> > from automatical updating?
> >> >
> >> > Thank you.
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Hermit Dave
Guest
Posts: n/a
 
      02-05-2004
you certainly can

--
Regards,
HD
Once a Geek.... Always a Geek
"Vik" <viktorum@==hotmail.com==> wrote in message
news:(E-Mail Removed)...
> Is it possible to release memory occupied by a Session object? E.g. will
> this work: Session("DS") = Nothing ?
>
> Vik
>
> "Hermit Dave" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> i see what you mean now.
>>
>> try using
>>
>> Session("DS") = DataSet11.Copy()
>>
>> that way you are explicitly saving a copy. I will have a play around with
>> this later on.
>>
>> --
>> Regards,
>> HD
>> Once a Geek.... Always a Geek
>> "Vik" <viktorum@==hotmail.com==> wrote in message
>> news:%23hHYK2$(E-Mail Removed)...
>> > Thank you Hermit. Here is my code.
>> >
>> > SqlDataAdapter1 and DataSet11 are created in design time.
>> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles MyBase.Load
>> >
>> > 'Put user code to initialize the page here
>> >
>> > Dim N0, N1, N2 As Int16, Str1, Str2 As String, DS As DataSet
>> >
>> > Session("DS") = DataSet11
>> >
>> > N0 = DataSet11.Tables(0).Rows.Count 'N0=0
>> >
>> > SqlDataAdapter1.Fill(DataSet11)
>> >
>> > DS = Session("DS")
>> >
>> > N1 = DataSet11.Tables(0).Rows.Count 'N1=3
>> >
>> > N2 = DS.Tables(0).Rows.Count 'N2=3
>> >
>> > Str1 = DataSet11.Tables(0).Rows(1)(1) 'Str1="Other"
>> >
>> > Str2 = DS.Tables(0).Rows(1)(1) 'Str2="Other"
>> >
>> > End Sub
>> >
>> > So, the dataset is saved in session state only once when it is empty.
>> > After
>> > the dataset is filled out its saved copy has all the new records. What
>> > I
>> > need and expected is that the dataset in session state keeps the old
>> > records
>> > (remains empty in this case) when the real dataset is updated.
>> >
>> > Vik
>> >
>> > "Hermit Dave" <(E-Mail Removed)> wrote in

> message
>> > news:%(E-Mail Removed)...
>> >> a code snip on how you are trying to use it would help. From my
>> >> current
>> >> understanding here's what i think:
>> >>
>> >> when you add objects to session they are added by value and not by
>> >> reference. ie one that you are refering to in you code is a local copy

> of
>> >> the object stored session.
>> >> any changes to the local copy would not be updated directly. you will
>> >> need
>> >> to manually update the object in session.
>> >>
>> >> --
>> >> Regards,
>> >> HD
>> >> Once a Geek.... Always a Geek
>> >> "Vik" <viktorum@==hotmail.com==> wrote in message
>> >> news:(E-Mail Removed)...
>> >> >A dataset is saved in session state. Then the dataset is filled out

> with
>> >> >the
>> >> > new records using a dataadapter. It appears then that the dataset

> saved
>> > in
>> >> > session state contains the new records even without saving the

> updated
>> >> > dataset.
>> >> >
>> >> > Why does this happen? How can I preserve the dataset saved in
>> >> > session
>> >> > state
>> >> > from automatical updating?
>> >> >
>> >> > Thank you.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 2.0 Session State and ASP.NET 1.1 Session State jnickfl1 ASP .Net 0 09-18-2006 03:23 PM
Unable to make the session state request to the session state server Maciek ASP .Net 0 09-15-2005 08:49 PM
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Mike Larkin ASP .Net 1 05-23-2005 12:33 PM
Unable to make the session state request to the session state server Not Liking Dot Net Today ASP .Net 0 04-21-2004 11:54 AM
unable to make the session state request to the session state server shamanthakamani ASP .Net 1 11-20-2003 04:51 AM



Advertisments