Using closes sql connection brought over by a function

Posted by iefpw on Stack Overflow See other posts from Stack Overflow or by iefpw
Published on 2012-10-05T03:04:20Z Indexed on 2012/10/05 3:37 UTC
Read the original article Hit count: 80

Filed under:

Would this using close this _connection?

using(SqlConnection _connection = Class1.GetSqlConnection())  
{   //code inside the connection
}

//connection should be closed/ended?

I'm just wondering because GetSqlConnection() is a static function of Class1 and the whole connection might not be closed because it is calling outside class' static function instead of straight?

 using(SqlConnection _connection = new SqlConnection(_connectionString)
 {   //code inside the connection
 }

© Stack Overflow or respective owner

Related posts about c#