示例#1
0
        private void OK_Click(object sender, EventArgs e)
        {
            string comment          = CommentBox.Text;
            int    price            = Int32.Parse(PriceBox.Text);
            string status           = StatusBox.Text;
            string connectionString = @"Data Source=LAPTOP-96NT0MPR;Initial Catalog=kursach;Integrated Security=True";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand();
                command.Connection = connection;
                string     sqlExpression = "UPDATE Заказы SET Комментарий_к_заказу = '" + comment + "', Цена = " + price + ", Статус_заказа = '" + status + "' WHERE Код_заказа = " + id;
                SqlCommand commandread   = new SqlCommand(sqlExpression, connection);
                commandread.ExecuteNonQuery();
            }
            prev_form.ItemsUpdate();
            this.Close();
        }