ExecuteNonQuery requires an open and available Connection. The connection\'s current state is closed.
What am I doing wrong here? I\'m assuming you can
Right here, your SqlDataReader will close the connection when it completes:
// Set all to 0
using (SqlCommand cmd = new SqlCommand("SELECT ID FROM tblSiteSettings WHERE ID = " + revertingID, cn))
{
// If it exists
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (rdr.Read())
{
rowsReturned = true;
}
rdr.Close();
}
Later, the "Set new active and reset others" section will fail, because the connection is closed.