M
mc
I'm writing a C# asp.net webpage.
I have a SQL connection and command inside using statements (as below),
if I do a response.redirect inside it will the auto-disposal code execute?
using (SqlConnection connect = DBHelper.GetConnection())
{
using (SqlCommand cmd = new SqlCommand("SomeSQL",connect)
{
SqlDataReader RS = cmd.ExecuteReader();
if (RS.Read())
{
//TODO - Do some stuff
RS.Close();
}
else
{
RS.Close();
Response.Redirect("someotheraddress");
}
}
}
I have a SQL connection and command inside using statements (as below),
if I do a response.redirect inside it will the auto-disposal code execute?
using (SqlConnection connect = DBHelper.GetConnection())
{
using (SqlCommand cmd = new SqlCommand("SomeSQL",connect)
{
SqlDataReader RS = cmd.ExecuteReader();
if (RS.Read())
{
//TODO - Do some stuff
RS.Close();
}
else
{
RS.Close();
Response.Redirect("someotheraddress");
}
}
}