1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
SqlConnection cs = new SqlConnection("server= ----; database= ----;User ID= -----;Password= ----");
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
if (radioButton1.Checked)
{
da.InsertCommand = new SqlCommand("INSERT INTO Table_Test (Préventif_Correctif) VALUES ('Préventif')", cs);
da.InsertCommand.Parameters.Add("@Préventif_Correctif", SqlDbType.VarChar).Value = radioButton1.Text;
}
else if (radioButton2.Checked)
{
da.InsertCommand = new SqlCommand("INSERT INTO Table_Test (Préventif_Correctif) VALUES ('Correctif')", cs);
da.InsertCommand.Parameters.Add("@Préventif_Correctif", SqlDbType.VarChar).Value = radioButton2.Text;
}
cs.Open();
da.InsertCommand.ExecuteNonQuery();
cs.Close(); |
Partager