Putting ado back into session state?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two web pages in my program. On one web page is the ado. On that page
I load the ado into session state. On the next page I unload the ado from
session and use it. I update the MSDE. Should I put the ado back into the
session state so the changes get propagated to the first page where the
original ado is or is everything current because I wrote to the database?
 
What you are describing (I think) is the process of saving an ADO.NET
DataSet, or DataTable that you have fetched into the Session state. This
approach is perfectly reasonable for applications--it scales fairly well up
to a point. The first page creates a rowset and displays it to the client
but saves the data in the Session state. The user changes the data and the
changes are returned in the viewstate. In the secondary page, you refetch
the dataset from the session state and post the changes to the DataSet and
then execute the DataAdapter Fill to post the changes to the Database. The
problem with the current version is that the changes made to the data by the
user are not automatically posted back to the DataSet--this step you have to
perform manually before you use the Update method.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
What exactly are you loading into session state?
I am a big proponent of trying to stay away from session and dependence on
it, because it leads you to create stateful servers.
But you can't load "ADO" into session, what "ADO.NET Object" are you loading
into session?

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
Dear Sahil,

I initially put the sqldataadapter and the dataset into session state. On my
other page it is telling me that the session[""]=null for both objects. One
guy told me in a post that I shouldn't use a wizard for the ado. And another
guy said that I should, after retrieving the objects from session state, set
them = new sql... and new dataset and then use them. I was originally told
to use session state instead of application state and cache. So I have a lot
to think about and am basically starting over with the whole thing. Let me
know what to do...Thanks

Spencer
 
Spencer,

There are multiple reasons why I don't like putting such large objects into
session state. Many will argue, but I stick by my point - stateless servers
are better. Though there is one gotcha - stateful servers are typically
lesser effort to program, but the point is they won't scale as well. So if
you need the scalability, stick with the ideal architecture. Another reason
is high availability, stateful servers mean you have one point of failure,
the IT guy reboots the machine, and everyone sits and waits.

The wizard - like any wizard - can never generate code that is as good as
handwritten code.

Specifically, the guy who told about to retreive an object from sessions
state, and then set it to new Sql... instance - that suggestion is no good
IMO because you put an object in session, and then overwrote it (lost it),
when u assigned it to a brand new instance.

The best place to start would be to read a book on ADO.NET, I've written one
and so have others, but if you have a problem description of what are you
trying to acheive, I'd be glad to help.

So for example one example problem description could be "I have a table in
the db, and I am trying to show it's contents in a paged manner". Something
like that :)

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/




Spencer H. Prue said:
Dear Sahil,

I initially put the sqldataadapter and the dataset into session state. On
my
other page it is telling me that the session[""]=null for both objects.
One
guy told me in a post that I shouldn't use a wizard for the ado. And
another
guy said that I should, after retrieving the objects from session state,
set
them = new sql... and new dataset and then use them. I was originally
told
to use session state instead of application state and cache. So I have a
lot
to think about and am basically starting over with the whole thing. Let me
know what to do...Thanks

Spencer

Sahil Malik said:
What exactly are you loading into session state?
I am a big proponent of trying to stay away from session and dependence
on
it, because it leads you to create stateful servers.
But you can't load "ADO" into session, what "ADO.NET Object" are you
loading
into session?

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/


message
 
Spencer,

The wizard is quick and dirty,
Handwritten code is better, but is not quick.

So what you use of the above, depends on your situation. The defacto choice
obviously is better quality i.e. handwritten - but you are a better judge of
that. I'd recommend picking up a book and understanding the ado.net model
before you write any code, and make decisions on which way to go.

In either case, I am not too fond of putting those objects in session state.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/




Spencer H. Prue said:
Dear Sahil,

I initially put the sqldataadapter and the dataset into session state. On my
other page it is telling me that the session[""]=null for both objects. One
guy told me in a post that I shouldn't use a wizard for the ado. And another
guy said that I should, after retrieving the objects from session state, set
them = new sql... and new dataset and then use them. I was originally told
to use session state instead of application state and cache. So I have a lot
to think about and am basically starting over with the whole thing. Let me
know what to do...Thanks

Spencer

Sahil Malik said:
What exactly are you loading into session state?
I am a big proponent of trying to stay away from session and dependence on
it, because it leads you to create stateful servers.
But you can't load "ADO" into session, what "ADO.NET Object" are you loading
into session?

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
Back
Top