1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
SqlConnection connection = new SqlConnection(str);
connection.Open();
System.Diagnostics.Debug.Write("connection établie");
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmdupdate = new SqlCommand("update TableInter set Affectation=@Affectation where id_role='" + id_roleTextBox.Text + "' and id_fonct='" + textBox2.Text + "' and id_droit='" + textBox1.Text + "'", connection);
cmdupdate.Parameters.Add(new SqlParameter("@Affectation", SqlDbType.Bit, 10, "Affectation"));
if (bool.Parse(dataGridView3[0, e.RowIndex].Value.ToString()) == true)
{
cmdupdate.Parameters["@Affectation"].Value = Convert.ToDouble(dataGridView3[0, e.RowIndex].Value);//true;
}
else
{
cmdupdate.Parameters["@Affectation"].Value = 0.0;//false;
}
cmdupdate.ExecuteNonQuery();
da.UpdateCommand = cmdupdate;
MessageBox.Show("OK");
connection.Close();
}
catch (Exception xcp)
{
MessageBox.Show(xcp.Message);
} |
Partager