473,725 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataset in Session state

Vik
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.
Nov 18 '05 #1
6 5126
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@==hot mail.com==> wrote in message
news:ed******** *****@tk2msftng p13.phx.gbl...
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.

Nov 18 '05 #2
Vik
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.EventArg s) 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.Table s(0).Rows.Count 'N0=0

SqlDataAdapter1 .Fill(DataSet11 )

DS = Session("DS")

N1 = DataSet11.Table s(0).Rows.Count 'N1=3

N2 = DS.Tables(0).Ro ws.Count 'N2=3

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

Str2 = DS.Tables(0).Ro ws(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" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.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 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@==hot mail.com==> wrote in message
news:ed******** *****@tk2msftng p13.phx.gbl...
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.


Nov 18 '05 #3
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@==hot mail.com==> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
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.EventArg s) 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.Table s(0).Rows.Count 'N0=0

SqlDataAdapter1 .Fill(DataSet11 )

DS = Session("DS")

N1 = DataSet11.Table s(0).Rows.Count 'N1=3

N2 = DS.Tables(0).Ro ws.Count 'N2=3

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

Str2 = DS.Tables(0).Ro ws(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" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.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 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@==hot mail.com==> wrote in message
news:ed******** *****@tk2msftng p13.phx.gbl...
>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.
>
>



Nov 18 '05 #4
Vik
Thank you. This works.

Vik

"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
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@==hot mail.com==> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
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.EventArg s) 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.Table s(0).Rows.Count 'N0=0

SqlDataAdapter1 .Fill(DataSet11 )

DS = Session("DS")

N1 = DataSet11.Table s(0).Rows.Count 'N1=3

N2 = DS.Tables(0).Ro ws.Count 'N2=3

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

Str2 = DS.Tables(0).Ro ws(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" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message news:%2******** ********@TK2MSF TNGP11.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 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@==hot mail.com==> wrote in message
news:ed******** *****@tk2msftng p13.phx.gbl...
>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.
>
>



Nov 18 '05 #5
Vik
Is it possible to release memory occupied by a Session object? E.g. will
this work: Session("DS") = Nothing ?

Vik

"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
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@==hot mail.com==> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
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.EventArg s) 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.Table s(0).Rows.Count 'N0=0

SqlDataAdapter1 .Fill(DataSet11 )

DS = Session("DS")

N1 = DataSet11.Table s(0).Rows.Count 'N1=3

N2 = DS.Tables(0).Ro ws.Count 'N2=3

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

Str2 = DS.Tables(0).Ro ws(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" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message news:%2******** ********@TK2MSF TNGP11.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 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@==hot mail.com==> wrote in message
news:ed******** *****@tk2msftng p13.phx.gbl...
>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.
>
>



Nov 18 '05 #6
you certainly can

--
Regards,
HD
Once a Geek.... Always a Geek
"Vik" <viktorum@==hot mail.com==> wrote in message
news:uK******** ******@TK2MSFTN GP12.phx.gbl...
Is it possible to release memory occupied by a Session object? E.g. will
this work: Session("DS") = Nothing ?

Vik

"Hermit Dave" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message
news:ey******** ******@tk2msftn gp13.phx.gbl...
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@==hot mail.com==> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
> 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.EventArg s) 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.Table s(0).Rows.Count 'N0=0
>
> SqlDataAdapter1 .Fill(DataSet11 )
>
> DS = Session("DS")
>
> N1 = DataSet11.Table s(0).Rows.Count 'N1=3
>
> N2 = DS.Tables(0).Ro ws.Count 'N2=3
>
> Str1 = DataSet11.Table s(0).Rows(1)(1) 'Str1="Other"
>
> Str2 = DS.Tables(0).Ro ws(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" <he************ @CAPS.AND.DOTS. hotmail.com> wrote in message > news:%2******** ********@TK2MSF TNGP11.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 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@==hot mail.com==> wrote in message
>> news:ed******** *****@tk2msftng p13.phx.gbl...
>> >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.
>> >
>> >
>>
>>
>
>



Nov 18 '05 #7

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

Similar topics

4
2846
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
2
1635
by: Martin | last post by:
Hi! I'm new to ASP.NET WebApplications and wonder whether I've missed something out when programming it. I'm grateful for any hints to this problem! Thanks very much for your efforts! Martin Description:
3
2207
by: Arthur Dzhelali | last post by:
Is there any way to cache dataset on one page and it will be accessible for one user? if you declare dataset shared it will stay on the server and page will be able reference to it on reload, but in this case it will be shared with other users who use the page. Right now I found work around it by saving each dataset as xml file with users's sessionid in file name and reading it on page reload. is there a better way?
3
1861
by: jhill | last post by:
i have a dataset object i put on my webform, i fill the dataset, bind it to my grid. the grid displays with my data. i put a button with no code in it, but just to have it force a postback. every time this happens, my dataset is set to nothing for the fun of it, i created 2 datasets and left one of them 'untouched', meaning it wasn't bound to anything... just filled with data. sure enough, it reset to "nothing" on a postback. this is...
8
1278
by: Ryu | last post by:
Is there any way to share a DataSet across more than 1 page? Do I have to retrieve the same Dataset everytime I go to a new page? Please advice, thanks
0
1095
by: Czar Eclarinal | last post by:
Hi Everyone, I've declared a datatable out of my typed dataset stored in session and add a new row to it. When state management is set to InProc and I modified the declared dataable, the changes reflect to the dataset. But when the session is OutProc (using SQL) , the changes doesnt reflect. For e.g. Sub Page_Load myDataSet AS myTypedDataSet
1
1150
by: Dhruba Bandopadhyay | last post by:
I have a DataGrid which has checkbox columns. The data source is a run-time created data set that I store in a session so I can rebind it during postbacks. I don't have a database or xml file, etc. I am wondering if it's possible to edit a dataset directly? So when I click on a checkbox it will change the value in the dataset and store it back into session? If this is not possible how can I use arrays or vectors to temporary store my...
7
2448
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone? Which is considered to be the 'best' way to cache a dataset and/or a crystal reports reportdocument object? ViewState? Session? Something else? Thanks in advance!
2
3006
by: zhshqzyc | last post by:
I am going to past a dataset from First.aspx to Second.aspx. A whole table will be displayed on First.aspx and partial columns will be displayed on Second.aspx. First.aspx view in browser works well if I exclude Second.aspx. But when Second.aspx is included in the project, an error happens. I can't find what is wrong in my code. System.NullReferenceException was unhandled by user code Message="Object reference not set to an...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.