473,789 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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. "(oleDBConnecti on)Session["dbConTProf ile"]"
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 1710
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.c om> wrote in message news:11******** **************@ g44g2000cwa.goo glegroups.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. "(oleDBConnecti on)Session["dbConTProf ile"]"
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1772
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an array). So if they are in a page were they already voted, they won't have the option to do so. The idea is that the session cookie lasts "forever", I don't want them voting for the same game everytime they get to the site. This isn't soo strict,...
0
1302
by: Grant | last post by:
My C# web application connects to an Access database using the OleDbConnection and OleDbDataReader. I have 3 other computers that connect to this server but very frequently I get an 'Unspecified error' message and the site becomes unusable. I have customErrors set to 'Off' so I can see what bit of code it is crashing at and it is always at line 78 below. (If I try and start a debug session - the server seems to reset itself and goes back...
2
2879
by: Grant | last post by:
My C# web application connects to an Access database using the OleDbConnection and OleDbDataReader. I have 3 other computers that connect to this server but very frequently I get an 'Unspecified error' message and the site becomes unusable. I have customErrors set to 'Off' so I can see what bit of code it is crashing at and it is always at line 78 below. (If I try and start a debug session - the server seems to reset itself and goes back...
2
5047
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to storing the session in Sql Server. Please let me know if Iam doing anything wrong. Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when
3
2338
by: Brad | last post by:
I am storing an array which contains about a dozen chracter items to a Session variable. Later, I need to use this array so I am doing the following: Dim eventTypes As String() = DirectCast(Session("EventTypes"), String()) If Date.Today <= closeDate Then If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee = Session("JRFee") Else thisFee = Session("PEFee") Else If eventTypes(cblEntries.SelectedIndex) = "J" Then thisFee =
10
2178
by: Mark Rae | last post by:
Hi, This relates to the previous thread "Disappearing Sessions", but is a bit more generic so I thought I'd start a new thread. This one relates to the storing of objects in Session once only to prevent the system having to constantly query the database for the same information. I'm currently upgrading a v1.1 app to v2 (that's all I seem to do these days!), and it contains a class called CUser which holds details of the currently...
9
7302
by: david | last post by:
I have a class with some business-logic and with every roundtrip, I need an instance of this class, so I have to create it, every time again. That doesn't seem very efficient. I thought it would be 'better' to store an instance of this class in a session-variable, so it's available all the time and needs to be instanced only once. Is this, generally speaking, a good idea, storing objects in session-variables ? Do you guys ever use this...
1
2829
by: None | last post by:
Hi, I have developed webshop application using asp.net 1.1. I'm using DataGrid in one of the pages of my site. During the page load the DataGrid will be binded by around 7500 products(rows). At the same time i'm storing the DataSet object in the Session Variable for later refinement. I'm using StateServer mode for storeing the session values. But in my server the W3wp.exe is taking 90 - 100 % CPU
3
2046
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve the information it contained on another page. This was significant because I am initially loading the data from the database, then storing relevent information in the object, I am allowing users to change the data then preview the modifications...
0
9666
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
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10139
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
9020
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...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.