J
John J. Hughes II
I was wondering about the follow code. I know that dispose is called on an
object when it leaves the using clause but was also wondering if the closed
statement was called on objects like Sql Connection and Data Readers?
Basically will I have problem or leave an object in memory if the closed is
not called below?
using(SqlConnection con = new SqlConnection())
{
con.Open();
using(SqlCommand cmd = con.CreateCommand)
{
... set up
using(SqlDataReader dr = cmd.ExecuteDateReader())
{
while(dr.Read())
..... do something
}
}
}
Regards,
John
object when it leaves the using clause but was also wondering if the closed
statement was called on objects like Sql Connection and Data Readers?
Basically will I have problem or leave an object in memory if the closed is
not called below?
using(SqlConnection con = new SqlConnection())
{
con.Open();
using(SqlCommand cmd = con.CreateCommand)
{
... set up
using(SqlDataReader dr = cmd.ExecuteDateReader())
{
while(dr.Read())
..... do something
}
}
}
Regards,
John