Web service with open db connection

M

Mantorok

Hi all

ASP.Net v2.0.

I have a web service that holds an "open" OleDb connection in one of its
session variables, when the session times out does this connection close, or
does it only close when another request comes through after the timeout?

Hope that makes sense.

Thanks
Kev
 
S

Steven Cheng[MSFT]

Hi Kev,

From your description, you're using OleDb components to access database in
ASP.NET 2.0 application. and you're wondering how to correctly open and
dispose the connection objects in the application's lifecycle, correct?

Based on my experience, in .net framework application which use ADO.NET
component to access database, you do not need to manually cache the
connection object since by default the .NET managed provider or underlying
OLEdb provider will use connecction pool to manage all the connections.
That means you do not need to manually open a connection object and keep it
open (stored in Session or other global storage). The recommended pattern
is open the connecction and close it as soon as you finish using it. The
connection pool will help you cache and pooling the underlying physical
connection to database and will improve performance when you frequently
open ADO.NET connection to database.

#ADO.Net connection pooling
http://weblogs.asp.net/sjoseph/archive/2005/03/23/395601.aspx

#Connection Pooling and Connection Management
http://www.dbazine.com/sql/sql-articles/charran2

#Get IT Done: How connection pooling can boost ADO.NET performance
http://articles.techrepublic.com.com/5100-6329_11-5034285.html

BTW, for webservice, session state is an ASP.NET specific feature that does
not conform to webservice standard, if you do want to cache some global
data, you can also consider using a static class member (such as a static
hashtable variable in a public class).

If you have any further questions or anything else wonder, please feel free
to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

You're welcome:)

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top