473,761 Members | 7,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open a connection to the pool

Hello!

How does this connection pool function actually ?
As I have been told is that when the connection is returned to the pool
the connection to the database is still open. What you do is that you just
return a still open connection to the pool.
When I open a connection I get an already open connection to the database.

Is this correct understood ?

//Tony
Jun 27 '08 #1
2 1927
Yes. If pooling is enabled (which it is by default on the SQL Server
provider), then calling Close() / Dispose() simply releases the real
connection to the pool. When you Open() a connection, it checks for
available pool connections with the same connection string, and uses
that. The pooled connection will be fully reset between uses, so you
don't need to worry about anything like orphaned temp tables, unusual
SET statements, etc.

Marc
Jun 27 '08 #2
Setting up the TCP connection between your Web application and SQL Server can
be an expensive operation. Connection pooling allows to reuse connections to
the database. Rather than setting up a new TCP connection on each request, a
new connection is set up only when one is not available in the connection
pool. When the connection is closed, it is returned to the pool where it
remains connected to the database, as opposed to completely tearing down that
TCP connection.

Of course you need to watch out for leaking connections. Always close your
connections when you're finished with them. Always call Close or Dispose
explicitly on your connection when you are finished with it. The CLR will
eventually destroy the class and force the connection closed, but you have no
guarantee when the garbage collection on the object will actually happen.

To use connection pooling optimally, there are a couple of rules to live by.
First, open the connection, do the work, and then close the connection. It's
okay to open and close the connection multiple times on each request if you
have to... rather than keeping the connection open and passing it around
through different methods. Second, use the same connection string (and the
same thread identity if you're using integrated authentication) . If you don't
use the same connection string, for example customizing the connection string
based on the logged-in user, you won't get the same optimization value
provided by connection pooling. And if you use integrated authentication
while impersonating a large set of users, your pooling will also be much less
effective. The .NET CLR data performance counters can be very useful when
attempting to track down any performance issues that are related to
connection pooling.
--
Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin
"Tony Johansson" wrote:
Hello!

How does this connection pool function actually ?
As I have been told is that when the connection is returned to the pool
the connection to the database is still open. What you do is that you just
return a still open connection to the pool.
When I open a connection I get an already open connection to the database.

Is this correct understood ?

//Tony
Jun 27 '08 #3

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

Similar topics

8
2061
by: DP | last post by:
I read some articles and post how to optimize te speed of asp pages regarding opening and closing DB connections but I am still not sure about this. Is it true that it doesn't matter how many times I open and destroy a DB connection on 1 single page? ---------------------------------------------------------- Set DataConn = Server.CreateObject("ADODB.Connection") Call DataConn.Open (...)
5
1659
by: Saulot | last post by:
Hi, Facing a big problem. In my Default.aspx page, I open a connection with ma Sql Server DataBase through my objects framework (A "SetDefaultConnectionString" property which open my connection... work fine with winforms) My Default.aspx page is a login one. When I log in, no problem, I got my Response.Redirect("DefaultEmployee.aspx") which works well. Then, I click on another Redirect which leads me to the employee's personnal...
6
8580
by: B B | last post by:
Okay, here is what's happening: I have a reasonably fast laptop (1.4 GHz Mobile M, so comparable to 2.5GHz P4) doing .net development. Running Windows XP pro, SP2 IIS is installed and running fine All SQL Servers I am referring to share a small (10 computers or so) LAN with a 100MB Switch. No other computers on the LAN exhibit this problem.
4
4380
by: Nevyn Twyll | last post by:
I've been working on an asp.net application and everything's been great. But suddenly, whether I'm tyring to use a database on my own machine, or on my server, I'm getting a timeout when trying to open a database connection. The error seems to happen regardless of what ASP.NET app I'm working with/trying to debug. It will open a few connections, Here's the error:
7
23922
by: Brian Kitt | last post by:
I frequently get the above error on my website. It happens only for short periods of times, then the error goes away. I cannot recreate this. I have an error trap that picks up this error. When it happens, I'll get 10 to 30 in a row, then it goes away for a week or so. It always comes back though. It's driving me crazy. At the start of a web page, I instantiate a 'global' module. The global module sets all of the connection...
1
3437
by: ramneekm | last post by:
hi all, i am working on a asp.net web app and using ado.net 's SqlClient Data Provider to connect to sqlserver 2005. I am getting the exception "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached." . Internally i am using a
7
13585
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get the error "ExecuteReader requires an open and available Connection. The connection's current state is Open, Executing." I do not use ExecuteReader, why the error says ExecuteReader. What does it mean ? When I get this error, is there a way for me...
11
3163
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hello, I have two Table Adapters that I am storing in a Cache using .NET 2.0 Web Service and the Database is SQL Server on Windows 2003 IIS6. Each of the two table adapters has its own Connection string. The reason that table adapters are in cache is because I would like to maintain the connection string that will not be closed for any Insert or Update as there are thousands of requests per minutes to the WS.
4
3432
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I am currently developing my first webapplication using .net (2.x) In a couple examples seen in the helpfile that came with VS2008 i see that they are opening a connection to the sql server. Issue a command or two, then close the connection. My question is, wouldn't it be better to have One connection open during the current session and when the session end, close the connection.
0
9531
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
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8780
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
7332
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
6609
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
5229
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
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
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.