Query in Datareader
- by bala
Hi All,
In the below code,
using (SqlDataReader dr = com.ExecuteReader(CommandBehavior.CloseConnection))
{
while (dr.Read())
{
_emailTemplate.EmailContent = dr["EMAILCONTENT"].ToString();
_emailTemplate.From = dr["EMAILFROM"].ToString();
_emailTemplate.Subject = dr["EMAILSUBJECT"].ToString();
}
}
I understand CommandBehavior.CloseConnection will close the connection object when datareader is closed. In the above code, when we use using with SqlDataReader, will it close the datareader before disposing it? in other other words, if i use using statement do i need to close the datareader manually?