Запрос Update MySQL C# datagridView in column?

Я хочу сделать так, чтобы при клике на любую строку велось автоматически значение в ячейку столбца и чтоб это значение введенное отобразилось и в БД, но получается только вставить в форму datagridView значение но не обновить таблицу БД. Помогите плиз разобраться!! Вот код, который я реализовал:

private void button3_Click(object sender, EventArgs e)
    {
        Form3 f = new Form3();
        int row = dataGridView1.CurrentCell.RowIndex;
        if (f.ShowDialog() == DialogResult.OK)
        {
            try
            {
                    MySqlCommand command = new MySqlCommand("Update transportation set active = @active where idtransportation=@id", conn);
                    command.Parameters.AddWithValue("@active", dataGridView1.Rows[row].Cells[7].Value = "X");
                    command.Parameters.AddWithValue("@id", dataGridView1.Rows[row].Cells[0].Value);
                    command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

Ответы (0 шт):