Storing OleDBConnection in Session

C

Curt tabor

Hi,
I have several pages in my app that all use the same
oleDBConnection(s). When this connection gets created, I store it as a
Session variable so that other pages can access it w/o having recreate
new connections every time they load.

I noticed during development that when ever the app first started, the
connection would not be in Session when I navigvated to a page that
used it. But with subsequent calls everything would be fine and the
connections would be there. I would only have a problem after not
running the app for a couple hours or so, and I figured this was
because the app had shut down. I was hoping this was just a glitch with
running under the IDE (VS 2005 RC).

I have now deployed this app to a server and whenever I try to get the
connection out of it's Session variable, it is not there - even on
subsequent requests. "(oleDBConnection)Session["dbConTProfile"]"
returns me null even though I have stored it there just seconds earlier
on another page.

Why isn't the object still in Session and am I doing this wrong to
begin with?

Thanks!

Curt
 
S

S.M. Altaf [MVP]

Is there a reason you have stored the connection object(s) in session variables? I think that's quite inefficient to begin with. Normally, in an ASP.NET page, once the objects have been used up, they are destroyed. By storing them in a session variable, you increase load upon the server's memory. I can only speculate how the site would perform when several visitors are using it. So to answer your last question, I don't feel you're doing it the right way.

I am not sure why it doesn't load up the first time, but session variables expire by default after a set period of time, and as a result the object may have been disposed of then.

-Altaf [MVP]


--------------------------------------------------------------------------------

All that glitters has a high refractive index.
www.mendhak.com

Hi,
I have several pages in my app that all use the same
oleDBConnection(s). When this connection gets created, I store it as a
Session variable so that other pages can access it w/o having recreate
new connections every time they load.

I noticed during development that when ever the app first started, the
connection would not be in Session when I navigvated to a page that
used it. But with subsequent calls everything would be fine and the
connections would be there. I would only have a problem after not
running the app for a couple hours or so, and I figured this was
because the app had shut down. I was hoping this was just a glitch with
running under the IDE (VS 2005 RC).

I have now deployed this app to a server and whenever I try to get the
connection out of it's Session variable, it is not there - even on
subsequent requests. "(oleDBConnection)Session["dbConTProfile"]"
returns me null even though I have stored it there just seconds earlier
on another page.

Why isn't the object still in Session and am I doing this wrong to
begin with?

Thanks!

Curt
 
C

Curt tabor

Yeah, that is pretty bad - duplicating all that for every session.
Thanks.

Curt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top