471,319 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Storing OleDBConnection in Session

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

Nov 19 '05 #1
2 1584
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

"Curt tabor" <ct****@oneil.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.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

Nov 19 '05 #2
Yeah, that is pretty bad - duplicating all that for every session.
Thanks.

Curt

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Francisco | last post: by
reply views Thread by Grant | last post: by
2 posts views Thread by Grant | last post: by
3 posts views Thread by Brad | last post: by
reply views Thread by rosydwin | last post: by

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.