Example #1
0
        public static void updateRound(ROUND round)
        {
            string constr = WebConfigurationManager.ConnectionStrings["myConnectionString"].ToString();

            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("UPDATE [ROUND] SET [from] = @from1, [to] = @to1 WHERE [round] = 1"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@from1", round.from1);
                    cmd.Parameters.AddWithValue("@to1", round.to1);
                    cmd.Connection = con;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                using (SqlCommand cmd = new SqlCommand("UPDATE [ROUND] SET [from] = @from2, [to] = @to2 WHERE [round] = 2"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@from2", round.from2);
                    cmd.Parameters.AddWithValue("@to2", round.to2);
                    cmd.Connection = con;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                using (SqlCommand cmd = new SqlCommand("UPDATE [ROUND] SET [from] = @from3, [to] = @to3 WHERE [round] = 3"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@from3", round.from3);
                    cmd.Parameters.AddWithValue("@to3", round.to3);
                    cmd.Connection = con;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
        }