473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Session state problem

I have a peculiar problem. I have a simple web application which loads
some data from the oracle table and display in the datagrid in the
webpage and datagrid has page enabled which shows 10 rows at a page.I
have a search criteria to search the records based on the data range i
give
This is what i have done, in the !IsPostBack section. I am setting up
the oracle connection, creating dataset object, datadapter and i aslo
load the data from the database into dataset and move all dataset,
datadapter, and connection object to session object. Now user can do
different operations withe records, like he select a row from grid and
there is button on in column of the grid to update , so what i do ,
update the dataset object for that particular row and then when next
time page load is called, i call dataadapter.update to update the data
back to the database. so my dataproviders objects are stored in the
session object. First of all is it a good way to do this?

Second when the session ends, and if the user comes back and does some
operation, it going to fail to update because the session variables
are destroyed and it will generate an error. What should i do to solve
this problem? Or if session object is not a good place to store this
dataprovider object, where shoould i store?. My page doesn't have a
user login, i am just using the default session created by asp.net.
Please help me, its very urgent
venky
Nov 18 '05 #1
14 2237
> First of all is it a good way to do this?

We can stop right there, because no, it is not a good way to do this. It
sounds like you're coming from an ASP background, where Connection Pooling
was not part of the platform. With ASP.Net, your best bet is to open and
close your Connections as quickly as possible, to release them back into the
pool.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Venkat Chellam" <ve************@yahoo.com> wrote in message
news:ac**************************@posting.google.c om...
I have a peculiar problem. I have a simple web application which loads
some data from the oracle table and display in the datagrid in the
webpage and datagrid has page enabled which shows 10 rows at a page.I
have a search criteria to search the records based on the data range i
give
This is what i have done, in the !IsPostBack section. I am setting up
the oracle connection, creating dataset object, datadapter and i aslo
load the data from the database into dataset and move all dataset,
datadapter, and connection object to session object. Now user can do
different operations withe records, like he select a row from grid and
there is button on in column of the grid to update , so what i do ,
update the dataset object for that particular row and then when next
time page load is called, i call dataadapter.update to update the data
back to the database. so my dataproviders objects are stored in the
session object. First of all is it a good way to do this?

Second when the session ends, and if the user comes back and does some
operation, it going to fail to update because the session variables
are destroyed and it will generate an error. What should i do to solve
this problem? Or if session object is not a good place to store this
dataprovider object, where shoould i store?. My page doesn't have a
user login, i am just using the default session created by asp.net.
Please help me, its very urgent
venky

Nov 18 '05 #2


Thanks for replying. Can you eloborate more what i am suppose to do? I
never worked on asp either, this is the first time i am working with
some webapplication.

can you tell me more in detail what ia m suppose to do or some sample
code?
venky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
Elaborate? Well, when you want to work with your database, open a
Connection, do your work, and close it immediately.

You may want to create a class of static database utility functions that you
can use whenever you need to connect to your database. I believe Microsoft
makes some of these available, although I'm not sure where (I wrote my own).
Hopefully, someone else here can tell you that.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"venkat chellam" <ve************@yahoo.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...


Thanks for replying. Can you eloborate more what i am suppose to do? I
never worked on asp either, this is the first time i am working with
some webapplication.

can you tell me more in detail what ia m suppose to do or some sample
code?
venky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4
what makes you think i am keep the connection open. I opening the
connection, getting the data using datadapter and filling it in dataset
and closing the connection. All my data is in the dataset object. When i
need to update, dataadapter opens it and closes it after it updates. In
my all finally statatment of try block, i have database.close if its
open. Only thing i am putting inside the session object is my dataset
object and dataadapter object and connection object which is closed and
i open it when i need it. But the point is after the session ends, my
dataset object is not valid and if user tries to change some thing it
gives error.My point is what particular step i am suppose to take when
session ends?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5
It would really help if you quote the thread you're replying to. I'm having
a difficult time trying to remember what started this thread...
what makes you think i am keep the connection open.
I suppose your telling me that you were persisting a Connection in Session
State led me to believe that. You are the first person I've run across that
stores a disconnected Connection class instance in Session State. And if I
recall correctly, you didn't mention that it was disconnected.

Not sure what you mean by "valid." A DataSet is a disconnected set of data.
"Valid" is not a property of the DataSet class.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"venkat chellam" <ve************@yahoo.com> wrote in message
news:eu**************@tk2msftngp13.phx.gbl... what makes you think i am keep the connection open. I opening the
connection, getting the data using datadapter and filling it in dataset
and closing the connection. All my data is in the dataset object. When i
need to update, dataadapter opens it and closes it after it updates. In
my all finally statatment of try block, i have database.close if its
open. Only thing i am putting inside the session object is my dataset
object and dataadapter object and connection object which is closed and
i open it when i need it. But the point is after the session ends, my
dataset object is not valid and if user tries to change some thing it
gives error.My point is what particular step i am suppose to take when
session ends?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #6
Ok, let me explain you my whole project what i am doing and then tell me
whats going wrong and what i am suppose to do
1. I am creating a simple webapplication. First page on the application
contains a search criteria with two datetime control. The page also
contains a webgrid control

2. When the users selects a datarange from the datetime controls, and
hit the search button, it suppose to run a query and display the data in
the datagrid.

3. What i am doing is in PageLoad event !IsNotPostBack, i am creating a
OracleConnection object with appropriate connection string and then
opening it. I create a Oracledatadapter object and set the selectcommand
to appropriate SQL query and also set updatecommand to stored procedure
name and create paramaters. Then i create a blank dataset object and
fill with dataadapter.fill(). Then i bind the grid with dataset view for
appropriate table. I move the dataset object, dataadapter object to the
session object for future page postback events

4. Grid has one column, which has a linkbutton and when i click on it,
i can update that row in the grid. OnEditCommand event, what i do is get
the row which need to be modified. Get the earlier stored dataset object
from the session object, get the appropriate row for which the update is
needed and then update it. LIke that the user can update couple of rows
and then finally when the page is reloaded , in page render event, i
update the data from the dataset back to database using stored
DataAdapter object in the session object.

Now whatever i am doing is right or wrong?

5. My problem now is if the session ends, dataset object and datadapter
object and some other session objects are destroyed , and if user is
alredy in the page and selects the row and updates it fails because
dataset object from the session is not valid any more.
I know i am doing something wrong, i am very new to web application and
asp.net. I hope i detailed what i am doing, you tell me what i am doing
wrong or how can i improve. Thanks for being so patient

venky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #7
I Agree but still I think sharing database connection across multiple pages is still good idea for scenarios
where you are connecting to legacy systems using system.data.odbc namespace and it puts system to death for 1 or more seconds.

"Kevin Spencer" <ks******@takempis.com> wrote in message news:uK*************@tk2msftngp13.phx.gbl...
First of all is it a good way to do this?


We can stop right there, because no, it is not a good way to do this. It
sounds like you're coming from an ASP background, where Connection Pooling
was not part of the platform. With ASP.Net, your best bet is to open and
close your Connections as quickly as possible, to release them back into the
pool.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Venkat Chellam" <ve************@yahoo.com> wrote in message
news:ac**************************@posting.google.c om...
I have a peculiar problem. I have a simple web application which loads
some data from the oracle table and display in the datagrid in the
webpage and datagrid has page enabled which shows 10 rows at a page.I
have a search criteria to search the records based on the data range i
give
This is what i have done, in the !IsPostBack section. I am setting up
the oracle connection, creating dataset object, datadapter and i aslo
load the data from the database into dataset and move all dataset,
datadapter, and connection object to session object. Now user can do
different operations withe records, like he select a row from grid and
there is button on in column of the grid to update , so what i do ,
update the dataset object for that particular row and then when next
time page load is called, i call dataadapter.update to update the data
back to the database. so my dataproviders objects are stored in the
session object. First of all is it a good way to do this?

Second when the session ends, and if the user comes back and does some
operation, it going to fail to update because the session variables
are destroyed and it will generate an error. What should i do to solve
this problem? Or if session object is not a good place to store this
dataprovider object, where shoould i store?. My page doesn't have a
user login, i am just using the default session created by asp.net.
Please help me, its very urgent
venky


Nov 18 '05 #8

how should i share the connection
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #9
Okay, I'm following you better now.

Storing anything more than your DataSet is Session accomplishes nothing. As
I mentioned, you may want to create a class of static methods for working
with data. A method for getting a DataSet can open its own Connection, get
the data, close the Connection, and return the DataSet. End of story. All
you have to do is call it and get the DataSet it returns. Then you can store
that in Session or any other cache mechanism you like.

Your real problem is the question you asked about what to do if Session is
lost. This is a common problem, due to the fact that Sessions time out and
disappear for a variety of reasons (such as the user goin gout for a cup of
coffee and coming back). The solution is really quite simple: Whenever you
use Session State, you must always handle the eventuality that a Session
will be lost. This means that, any time you want to access Session, you need
to check if your Session variable is still there. If it isn't, provide some
means of recovering it, such as informing the user that their Session has
expired, and redirecting them, or simply re-querying the database - whatever
is most appropriate for your situation. Just remember that you must always
check for Session objects prior to attempting to use them.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"venkat chellam" <ve************@yahoo.com> wrote in message
news:#k**************@TK2MSFTNGP12.phx.gbl...
Ok, let me explain you my whole project what i am doing and then tell me
whats going wrong and what i am suppose to do
1. I am creating a simple webapplication. First page on the application
contains a search criteria with two datetime control. The page also
contains a webgrid control

2. When the users selects a datarange from the datetime controls, and
hit the search button, it suppose to run a query and display the data in
the datagrid.

3. What i am doing is in PageLoad event !IsNotPostBack, i am creating a
OracleConnection object with appropriate connection string and then
opening it. I create a Oracledatadapter object and set the selectcommand
to appropriate SQL query and also set updatecommand to stored procedure
name and create paramaters. Then i create a blank dataset object and
fill with dataadapter.fill(). Then i bind the grid with dataset view for
appropriate table. I move the dataset object, dataadapter object to the
session object for future page postback events

4. Grid has one column, which has a linkbutton and when i click on it,
i can update that row in the grid. OnEditCommand event, what i do is get
the row which need to be modified. Get the earlier stored dataset object
from the session object, get the appropriate row for which the update is
needed and then update it. LIke that the user can update couple of rows
and then finally when the page is reloaded , in page render event, i
update the data from the dataset back to database using stored
DataAdapter object in the session object.

Now whatever i am doing is right or wrong?

5. My problem now is if the session ends, dataset object and datadapter
object and some other session objects are destroyed , and if user is
alredy in the page and selects the row and updates it fails because
dataset object from the session is not valid any more.
I know i am doing something wrong, i am very new to web application and
asp.net. I hope i detailed what i am doing, you tell me what i am doing
wrong or how can i improve. Thanks for being so patient

venky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #10

thank you very much. I did change my code to remove datadapter and
connection object from my session. Now regarding the session end, you
said, i have to check the validity of session object, how do i do that?
In my page load, is there a way to see the session object is valid or
not?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #11
Not valid. Session State will always be there. You need to check if the
Session variables you create are still there. Example:

if (Session["SomeDataTable"] != null)
....

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"venkat chellam" <ve************@yahoo.com> wrote in message
news:uj**************@TK2MSFTNGP11.phx.gbl...

thank you very much. I did change my code to remove datadapter and
connection object from my session. Now regarding the session end, you
said, i have to check the validity of session object, how do i do that?
In my page load, is there a way to see the session object is valid or
not?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #12
Ok thank you very much for all your help

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #13

HI kevin,

Can you ask you few more questions in asp.net?

I want to know how do i update the status bar in the client browser? I
mean i want to show show which user logged in? I am using windows user
login of the client as login id

venkat
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #14
Hi venkat,

That would be done using JavaScript. Example:

window.status = "Spank your mamma.";

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"venkat chellam" <ve************@yahoo.com> wrote in message
news:#M**************@TK2MSFTNGP09.phx.gbl...

HI kevin,

Can you ask you few more questions in asp.net?

I want to know how do i update the status bar in the client browser? I
mean i want to show show which user logged in? I am using windows user
login of the client as login id

venkat
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #15

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

Similar topics

7
by: Billy Jacobs | last post by:
I am having a problem with my session variable being set to Null for no apparent reason. I am declaring it like the following when the user logs in. dim objUserInfo as new clsUserInfo 'Set...
5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
4
by: Daniel | last post by:
Hi I am having a problem sharing session between SSL and non-SSL asp.net pages I have F5 BigIP with sticky sessions working fine, but the problem is tha sticky session applies at the port level...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
5
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know...
9
by: cashdeskmac | last post by:
I have put a string into Session and tried to retrieve it on the next page I visit but the Session appears empty. I have exactly the same spelling for both adding and retrieving the value: ...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
11
by: Glenn | last post by:
Hi I've been experimenting with managing state using the Session object. I've created a simple WS with a couple of methods, one which sets a string value, another that retrieves it. Each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...

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.