Use "using" for SqlConnection"

  • Thread starter Thread starter MIchael
  • Start date Start date
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
 
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.
__________________________________
 
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.
 
Thanks, I actually find an article in MSDN about connectionpooling and it
mentioned the connection is not closed.
Thanks for helping

Michael
 
Back
Top