473,800 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2204
"=?Utf-8?B?R3JpZ3M=?=" <Gr***@discussi ons.microsoft.c om> wrote in
news:24******** *************** ***********@mic rosoft.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********@rog ers.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********@rog ers.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***@discussi ons.microsoft.c om> wrote in message
news:20******** *************** ***********@mic rosoft.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********@rog ers.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
7525
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 have an series of interactive HTML forms. The user begins a Cookie session. A database connection is opened and a transaction is begun. After the user goes through any number of pages where they update the database they finish on a page where...
1
6492
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 any suggestions! Thanks! The connection is already Open (state=Open). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where...
4
4632
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 type="checkbox" name="chk_Complete" value="<%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked"%>> The code to captures the checkbox value in the asp page that builds the sql string is follows
3
2615
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 database. To test, I've created two test aspx pages. Test1.aspx contains two buttons. The first button sets values in the session object and then navigates to Test2.aspx. Test2.aspx only displays the values in the session object. The second button...
14
4827
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 connection open all the time (as it's single user, this shouldn't be a problem). There is logic in the code to ensure that the connection is
1
2469
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 http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Order Record</title> <meta name="Microsoft Border" content="tlb, default"> </head>
6
2444
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 when user clicks on particular node it brings up totally different page with all the asp.net controls dynamically generated. Example: Tree view Control is as follow:
3
1415
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 use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. We installed the custom state database using... aspnet_regsql -S mysvrname -E -ssadd -sstype c -d mydbname ....and can see the database.
9
6283
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 only has read access to the users table so that users can log in. Once a user has been logged in successfully I want to escalate that user's access level to one appropriate to their role, which will include switching the postgres user they are...
0
9691
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
9551
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
10255
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
9092
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
7582
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
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2948
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.