Dataset in Session state | | |
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. | | | | re: Dataset in Session state
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:ed5CJv16DHA.804@tk2msftngp13.phx.gbl...[color=blue]
>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.
>
>[/color] | | | | re: Dataset in Session state
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" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in message
news:%23lauQj36DHA.2576@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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:ed5CJv16DHA.804@tk2msftngp13.phx.gbl...[color=green]
> >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[/color][/color]
in[color=blue][color=green]
> > 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.
> >
> >[/color]
>
>[/color] | | | | re: Dataset in Session state
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$6DHA.452@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in message
> news:%23lauQj36DHA.2576@TK2MSFTNGP11.phx.gbl...[color=green]
>> 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:ed5CJv16DHA.804@tk2msftngp13.phx.gbl...[color=darkred]
>> >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[/color][/color]
> in[color=green][color=darkred]
>> > 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.
>> >
>> >[/color]
>>
>>[/color]
>
>[/color] | | | | re: Dataset in Session state
Thank you. This works.
Vik
"Hermit Dave" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eyNKMKC7DHA.2712@tk2msftngp13.phx.gbl...[color=blue]
> 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$6DHA.452@TK2MSFTNGP11.phx.gbl...[color=green]
> > 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" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:%23lauQj36DHA.2576@TK2MSFTNGP11.phx.gbl...[color=darkred]
> >> 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[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> >> 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:ed5CJv16DHA.804@tk2msftngp13.phx.gbl...
> >> >A dataset is saved in session state. Then the dataset is filled out[/color][/color][/color]
with[color=blue][color=green][color=darkred]
> >> >the
> >> > new records using a dataadapter. It appears then that the dataset[/color][/color][/color]
saved[color=blue][color=green]
> > in[color=darkred]
> >> > session state contains the new records even without saving the[/color][/color][/color]
updated[color=blue][color=green][color=darkred]
> >> > dataset.
> >> >
> >> > Why does this happen? How can I preserve the dataset saved in session
> >> > state
> >> > from automatical updating?
> >> >
> >> > Thank you.
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color] | | | | re: Dataset in Session state
Is it possible to release memory occupied by a Session object? E.g. will
this work: Session("DS") = Nothing ?
Vik
"Hermit Dave" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eyNKMKC7DHA.2712@tk2msftngp13.phx.gbl...[color=blue]
> 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$6DHA.452@TK2MSFTNGP11.phx.gbl...[color=green]
> > 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" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:%23lauQj36DHA.2576@TK2MSFTNGP11.phx.gbl...[color=darkred]
> >> 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[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> >> 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:ed5CJv16DHA.804@tk2msftngp13.phx.gbl...
> >> >A dataset is saved in session state. Then the dataset is filled out[/color][/color][/color]
with[color=blue][color=green][color=darkred]
> >> >the
> >> > new records using a dataadapter. It appears then that the dataset[/color][/color][/color]
saved[color=blue][color=green]
> > in[color=darkred]
> >> > session state contains the new records even without saving the[/color][/color][/color]
updated[color=blue][color=green][color=darkred]
> >> > dataset.
> >> >
> >> > Why does this happen? How can I preserve the dataset saved in session
> >> > state
> >> > from automatical updating?
> >> >
> >> > Thank you.
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color] | | | | re: Dataset in Session state
you certainly can
--
Regards,
HD
Once a Geek.... Always a Geek
"Vik" <viktorum@==hotmail.com==> wrote in message
news:uK7cf1C7DHA.1804@TK2MSFTNGP12.phx.gbl...[color=blue]
> Is it possible to release memory occupied by a Session object? E.g. will
> this work: Session("DS") = Nothing ?
>
> Vik
>
> "Hermit Dave" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in message
> news:eyNKMKC7DHA.2712@tk2msftngp13.phx.gbl...[color=green]
>> 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$6DHA.452@TK2MSFTNGP11.phx.gbl...[color=darkred]
>> > 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" <hermitd.REMOVE@CAPS.AND.DOTS.hotmail.com> wrote in[/color][/color]
> message[color=green][color=darkred]
>> > news:%23lauQj36DHA.2576@TK2MSFTNGP11.phx.gbl...
>> >> 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[/color][/color]
> of[color=green][color=darkred]
>> >> 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:ed5CJv16DHA.804@tk2msftngp13.phx.gbl...
>> >> >A dataset is saved in session state. Then the dataset is filled out[/color][/color]
> with[color=green][color=darkred]
>> >> >the
>> >> > new records using a dataadapter. It appears then that the dataset[/color][/color]
> saved[color=green][color=darkred]
>> > in
>> >> > session state contains the new records even without saving the[/color][/color]
> updated[color=green][color=darkred]
>> >> > dataset.
>> >> >
>> >> > Why does this happen? How can I preserve the dataset saved in
>> >> > session
>> >> > state
>> >> > from automatical updating?
>> >> >
>> >> > Thank you.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >[/color]
>>
>>[/color]
>
>[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,501 network members.
|