B
bozzzza
If I did something like this :-
=======================================================================================
//Method to return a ref to an SqlConnection
private SqlConnection GetConnection()
{
SqlConnection conn = new SqlConnection(Globals.cCONN_STR);
return conn;
}
//Get the SubScription Info and Return the structure
protected void TestFunction()
{
string sqlstmt = "select * from test";
using (SqlCommand command = new SqlCommand(sqlstmt,GetConnection()))
{
//Do Something Here
}
}
========================================================================================
Because I have used the using statement the command object will call
its dispose method when it leaves the using scope.
But I was wondering what happens to the SqlConnection object in the
TestFunction(): does it get disposed when the command object gets
disposed?
Or would I have to do something like this before it left the using
block: command.Connection.Dispose()?
TIA
Simon
=======================================================================================
//Method to return a ref to an SqlConnection
private SqlConnection GetConnection()
{
SqlConnection conn = new SqlConnection(Globals.cCONN_STR);
return conn;
}
//Get the SubScription Info and Return the structure
protected void TestFunction()
{
string sqlstmt = "select * from test";
using (SqlCommand command = new SqlCommand(sqlstmt,GetConnection()))
{
//Do Something Here
}
}
========================================================================================
Because I have used the using statement the command object will call
its dispose method when it leaves the using scope.
But I was wondering what happens to the SqlConnection object in the
TestFunction(): does it get disposed when the command object gets
disposed?
Or would I have to do something like this before it left the using
block: command.Connection.Dispose()?
TIA
Simon