Use "using" for SqlConnection"

M

MIchael

I have a question regarding use the "using " statement for connection
object.

When use connection object, I used to put
using (SqlConnection conn=new SqlConnection("connectionstring"))
{
conn.open();
......

}

But then I saw one web
site(http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=353) said when
use the using statement, the connection will be removed from the connection
pool, is it the case? Can some one point at a MSDN document describe this?

Thanks;

Mike
 
W

William \(Bill\) Vaughn

Using has no effect on the connection pool. The documentation is wrong--it
was corrected in a later revision.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
M

Miha Markic

Hi,

In addition to Bill:
using just ensures that Dispose of the given object is invoked at the end of
the block - it acutally maps to try/finally block.
 
M

MIchael

Thanks, I actually find an article in MSDN about connectionpooling and it
mentioned the connection is not closed.
Thanks for helping

Michael
 

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

Top