I would like to add a record in my database.
There is my code below :
private void buttonAdd_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Insert into RDV (idUser,idClient,objet,objectif,DateRdv,commentaire)values('"+comboBox1.Text+"','"+comboBox2.Text+ "','" + textBox1.Text + "','" + textBox2.Text + "','" + dateTimePicker1.Text.ToString() + "','" + textBox4.Text + "')", con);
sda.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("Le RDV a été ajouté avec succés !");
}
but an error happens:
Conversion failed when converting the varchar value 'John' to data type int.
How should I convert it? Please help me.
Thanks in advance.
RDV?'"+comboBox1.Text+"','"+comboBox2.Text+ "','"and It should becomboBox1.SelectedValue