471,306 Members | 917 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Pooling and SqlConnetion?

Hi all
I use 'Pooling=true;' in my connection string;
how can I disable 'pooling' in my application and close all connections???
thanks in advance
Jan 18 '06 #1
4 1650
perspolis,

I wouldn't necessarily do that. What is the purpose here? Just killing
a database connection is a bad thing, since you could be closing it in the
middle of an important operation.

You can always just not place "pooling=true" in the connection string,
and the connections will not be pooled, they will close when your code
closes them.

Of course, you should always use the using statement to make sure your
connections close when you are done using them.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"perspolis" <re*****@hotmail.com> wrote in message
news:ei*************@TK2MSFTNGP15.phx.gbl...
Hi all
I use 'Pooling=true;' in my connection string;
how can I disable 'pooling' in my application and close all connections???
thanks in advance

Jan 18 '06 #2
Pooling=true is the default, it will be on even if this element is not
present in the connection string. change it to:

Pooling=false;

Now as long as you Close each connection, no connections will be returned to
the pool. I think its important to understand that pooled connection objects
are just connection objects, they are not left "Open" - until you open them.

Why do you want to disable connection pooling?

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"perspolis" wrote:
Hi all
I use 'Pooling=true;' in my connection string;
how can I disable 'pooling' in my application and close all connections???
thanks in advance

Jan 18 '06 #3
Nicholas Paldino [.NET/C# MVP] wrote:
I wouldn't necessarily do that. What is the purpose here? Just killing
a database connection is a bad thing, since you could be closing it in the
middle of an important operation.

You can always just not place "pooling=true" in the connection string,
and the connections will not be pooled, they will close when your code
closes them.

Of course, you should always use the using statement to make sure your
connections close when you are done using them.


That doesn't make sure the physical connections will be closed though.

Before now I've had cause to want to remove connections from the pool
having killed them on the SQL Server side (if you're not careful, the
pool doesn't notice that they've died, and you get an exception next
time you try to use them).

Fortunately, in .NET 2.0 you can use SqlConnection.ClearAllPools (or
ClearPool for a specific pool) to do this. Unfortunately I wasn't
working with 2.0 at the time :(

Jon

Jan 18 '06 #4
Jon Skeet [C# MVP] wrote:
Of course, you should always use the using statement to make sure your
connections close when you are done using them.


That doesn't make sure the physical connections will be closed though.


Just to anticipate a reply - yes, it will kill the physical connections
if you have pooling turned off to start with. I hadn't noticed that bit
of Nick's reply :)

Jon

Jan 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by John | last post: by
18 posts views Thread by Rob Nicholson | last post: by
1 post views Thread by Lenny Shprekher | last post: by
4 posts views Thread by Susan Baker | last post: by
3 posts views Thread by howachen | last post: by
16 posts views Thread by crbd98 | last post: by
3 posts views Thread by fniles | last post: by
reply views Thread by rosydwin | last post: by

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.