i have modify your try block just copy and paste in your code
try
{
con = new SqlConnection(constr);
con.Open();
cmd = new SqlCommand("insertuser", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@usertype", ucode);
cmd.Parameters.AddWithValue("@sqrtyans", txtans.Text);
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("<script>alert('Data is inserted')</script>");
}
Your Have not open the connection to execute your sql query