I am researching some errors with "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."
message. I am assuming that the connection pool ran out of connections
(though it could certainly be something else).
So I've looked through the code and it does close Connections (in the
finally clause), but doesn't .Dispose of them. Do I have to dispose of
the connections? Do connections not get released unless you dispose of
them?
Thanks 4 5851
Frank,
For most connections, Close and Dispose are the same thing. The reason
I say most is that the base class for connections, DbConnection (or
DbDataConnection, I forget which one it is), the Close method and Dispose
method pretty much share the same code path. However, certain providers can
override that code path.
I would advise not doing it yourself in the finally statement, rather,
just wrapping everything in a using statement.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Frank Rizzo" <no**@none.com> wrote in message
news:ey**************@TK2MSFTNGP04.phx.gbl... I am researching some errors with "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." message. I am assuming that the connection pool ran out of connections (though it could certainly be something else).
So I've looked through the code and it does close Connections (in the finally clause), but doesn't .Dispose of them. Do I have to dispose of the connections? Do connections not get released unless you dispose of them?
Thanks
Nicholas Paldino [.NET/C# MVP] wrote: Frank,
For most connections, Close and Dispose are the same thing. The reason I say most is that the base class for connections, DbConnection (or DbDataConnection, I forget which one it is), the Close method and Dispose method pretty much share the same code path. However, certain providers can override that code path.
I would advise not doing it yourself in the finally statement, rather, just wrapping everything in a using statement.
However, per your statement, wouldn't this cause a problem, if I were to
use another provider? Since using only calls .Dispose, but not .Close?
Also, why would you advise using the 'using' statement, rather than
manually closing/disposing connections in the finally section? Other
than code clarity, are there any downsides?
Regards
Frank,
I wasn't saying that you should use another provider. I'm saying that
some providers can override the behavior that I mentioned, but for the most
part, they do not.
As for the using statement, you are right, I suggest it for the sake of
code clarity.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Frank Rizzo" <no**@none.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Nicholas Paldino [.NET/C# MVP] wrote:
>Frank,
For most connections, Close and Dispose are the same thing. The reason I say most is that the base class for connections, DbConnection (or DbDataConnection, I forget which one it is), the Close method and Dispose method pretty much share the same code path. However, certain providers can override that code path.
I would advise not doing it yourself in the finally statement, rather, just wrapping everything in a using statement.
However, per your statement, wouldn't this cause a problem, if I were to
use another provider? Since using only calls .Dispose, but not .Close?
Also, why would you advise using the 'using' statement, rather than
manually closing/disposing connections in the finally section? Other than
code clarity, are there any downsides?
Regards
>>
Besides clarity, a using statement guarantees that Dispose is called no
matter how you're exiting the block (ie, even if there's an exception).
If you're already calling dispose in a finally block, there will be
no difference except that the code is cleaner.
Andy
Frank Rizzo wrote:
Nicholas Paldino [.NET/C# MVP] wrote:
Frank,
For most connections, Close and Dispose are the same thing. The reason
I say most is that the base class for connections, DbConnection (or
DbDataConnection, I forget which one it is), the Close method and Dispose
method pretty much share the same code path. However, certain providers can
override that code path.
I would advise not doing it yourself in the finally statement, rather,
just wrapping everything in a using statement.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Martin |
last post by:
Dear Group
Sorry for posting this here. I'm desperate for a solution to this
problem and thought some of you might have come across it with .NET
and SQL Server.
Let's assume I've the following...
|
by: Kamalanathan T. |
last post by:
Hi,
We have developed an Web application in ASP.NET with C#
and we r using SQL Server 2000. We get the Timeout expired
error, when more than 300 concurrent users hit the site.
I hagone thru...
|
by: Guoqi Zheng |
last post by:
Dear sir,
I keep getting the following errors on one of my sites after clicking for
many times.
Timeout expired. The timeout period elapsed prior to obtaining a connection
from the pool. This...
|
by: UJ |
last post by:
We have recently started getting the following error message:
Timeout expired. The timeout period elapsed prior to obtaining a connection
from the pool. This may have occurred because all pooled...
|
by: luresh |
last post by:
Hi EveryBody :
i am using following code ,it is working fine most of the time but some time
"Unable to read data from the transport connection: The connection was closed"
error occured in the...
|
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...
|
by: =?Utf-8?B?QnNtZW5nZW4=?= |
last post by:
I am trying to make sure that the local connection is up. I have presently
been using the NetworkChange.NetworkAvailabilityChanged Event for this. Is
there a better way to do this?
Also, I...
|
by: Tony Johansson |
last post by:
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...
|
by: anumsajeel |
last post by:
Hi,
Error Message:-
error connecting: Timeout expired. The timeout period elapsed prior to
obtaining a connection from the pool. This may have occurred because all pooled
connections were...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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...
| |