473,406 Members | 2,273 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,406 software developers and data experts.

Database Connection and Session State

Hello,

I have a web service that reads its web.config file to connect to an Oracle
database. There are a number of methods in this socalled BACKBONE that
either send inforomation to or from the database. That works great.

I have the INTERFACE which is what the user sees. When the page is first
navigated to, it creates an object of the BACKBONE and calls certain Web
Methods to get data so I may populate dropdown lists and such.

That works great too. :-)

However, my DBA wanted me to set an action for each "program" that connects
to his database. I can create this "action" no problem. The only issue is
that it happens to create 11 entries/connection to the database. Bascially 1
for each of the 11 seperate calls I make to the BACKBONE.

I thought I could just create the connection in the BACKBONE's Global.asax
file as a session variable and use it when I need to connect to the DB but
that had no difference. Still 11 connections. I understand that the web
service simple is being called 11 seperate times.

My question is, is there any way to keep that web-service open? Or some way
of at least storing the connection in a session variable that will stay? I
have to believe I am not the only person creating a Web Service to do all of
the DB grunt work. Are we all wasting connections and the overhead of
connections connecting? Am I missing something here?

Please help,
Thanks in advance
--
Thanx,
Grigs
Nov 19 '05 #1
3 2178
"=?Utf-8?B?R3JpZ3M=?=" <Gr***@discussions.microsoft.com> wrote in
news:24**********************************@microsof t.com:
I thought I could just create the connection in the BACKBONE's
Global.asax file as a session variable and use it when I need to
connect to the DB but that had no difference. Still 11 connections.
I understand that the web service simple is being called 11 seperate
times.
Are you storing the db connection as an application variable or session
variable?

If you want to have 1 connection that is shared across all instances,
place your connection in an application variable.

Are we all wasting
connections and the overhead of connections connecting? Am I missing
something here?


BTW, you're not wasting connections... When you share 1 connection, you
might end up with queued request (you may have to build the queuing
mechanism yourself). A connection can only process 1 request at a time,
so if you have 5 users hitting your web service, users 2-5 might have to
wait until the connection is freed by user 1 before they can submit a
query.

If you'll pulling a subset of data frequency, consider caching the data
locally either in a shared dataset or in a local database.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2
> > I thought I could just create the connection in the BACKBONE's
Global.asax file as a session variable and use it when I need to
connect to the DB but that had no difference. Still 11 connections.
I understand that the web service simple is being called 11 seperate
times.
Are you storing the db connection as an application variable or session variable?


Right now it is a SESSION variable created in the Session_Start. To test
it, I had it send me an email each time a "session" was started. I received
11 emails, one for each of the tasks I asked for. Even though they really
came from the same single object on the INTERFACE side.
If you want to have 1 connection that is shared across all instances,
place your connection in an application variable.
Not sure how good a single connection for EVERYONE would be. Is there a way
to have it per SESSION? Some switch, attribute, variable that I am missing?

I tried SQL Server State and that failed because of serialization.
I tried creating the object in the INTERFACE and passing it back and that
was a serialization issue as well.

Is it difficult to write a serialize/deserialize method/class/object? I
have seen some code on this but am not 100% sure about it.

Are we all wasting
connections and the overhead of connections connecting? Am I missing
something here?
BTW, you're not wasting connections... When you share 1 connection, you
might end up with queued request (you may have to build the queuing
mechanism yourself). A connection can only process 1 request at a time,
so if you have 5 users hitting your web service, users 2-5 might have to
wait until the connection is freed by user 1 before they can submit a
query.

If you'll pulling a subset of data frequency, consider caching the data
locally either in a shared dataset or in a local database.


Thank you for your help.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 19 '05 #3
It is extremely bad practice and could lead to serious problems
with performance of your application when you put it into
production. This applys to static objects, application objects,
and/or session objects.

Best practice says you open a connection, perform your task,
and close your connection as soon as possible. Check with
your DBA to see if some sort of connection pooling is available
with the Oracle .NET Providers (the sql server provider offers
this but I'm not certain whether Oracle implements it or not).

--
Robbe Morris - 2004/2005 Microsoft MVP C#

Earn money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp

"Grigs" <Gr***@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
> I thought I could just create the connection in the BACKBONE's
> Global.asax file as a session variable and use it when I need to
> connect to the DB but that had no difference. Still 11 connections.
> I understand that the web service simple is being called 11 seperate
> times.


Are you storing the db connection as an application variable or session
variable?


Right now it is a SESSION variable created in the Session_Start. To test
it, I had it send me an email each time a "session" was started. I
received
11 emails, one for each of the tasks I asked for. Even though they really
came from the same single object on the INTERFACE side.
If you want to have 1 connection that is shared across all instances,
place your connection in an application variable.


Not sure how good a single connection for EVERYONE would be. Is there a
way
to have it per SESSION? Some switch, attribute, variable that I am
missing?

I tried SQL Server State and that failed because of serialization.
I tried creating the object in the INTERFACE and passing it back and that
was a serialization issue as well.

Is it difficult to write a serialize/deserialize method/class/object? I
have seen some code on this but am not 100% sure about it.

> Are we all wasting
> connections and the overhead of connections connecting? Am I missing
> something here?


BTW, you're not wasting connections... When you share 1 connection, you
might end up with queued request (you may have to build the queuing
mechanism yourself). A connection can only process 1 request at a time,
so if you have 5 users hitting your web service, users 2-5 might have to
wait until the connection is freed by user 1 before they can submit a
query.

If you'll pulling a subset of data frequency, consider caching the data
locally either in a shared dataset or in a local database.


Thank you for your help.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 19 '05 #4

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

Similar topics

16
by: noah | last post by:
Does PHP have a feature to associate Cookie sessions with a persistent database connection that will allow a single transaction across multiple HTTP requests? Here is how I imagine my process: I...
1
by: ST | last post by:
This is my other error when I click on Immunoflourescence. I believe this is related to the other error I just posted (Input string was not in a correct format.) Please let me know if you have...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
3
by: William | last post by:
Hi I have an ASP.NET application that connects to an Access database. Everything works fine except for the Session object. Data in the session object is lost after I've made a call to the...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
6
by: DNB | last post by:
I would like to know what you guys think is the best way to access data: Asp.Net session vs. Database Queries. In our application we are using asp.net tree view to display hierarchical data and...
3
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
We are setting up a web farm and want to store session state on a SQL Server 2005 Enterprise sp2 database. But when the web sites try to access the session state we get the error... Unable to...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.