I have a probleme : this the code :
private void modifier_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\ElliteBook\source\repos\Ecole Prive El Faouz\Data.mdf; Integrated Security = True");
con.Open();
string query = "update eleve set nom = '" +nom.Text+ "'where matricule = '" +recherche.Text+ "'";
SqlDataAdapter sda = new SqlDataAdapter(query, con);
sda.SelectCommand.ExecuteNonQuery();
con.Close();
MessageBox.Show("'"+recherche.Text+"'")
}
and this the table sql :
CREATE TABLE [dbo].[eleve] (
[matricule] INT IDENTITY (10000, 1) NOT NULL,
[nom] NVARCHAR (MAX) NULL,
[prenom] NVARCHAR (MAX) NULL,
[nom_pere] NVARCHAR (MAX) NULL,
[datenaissance] NVARCHAR (MAX) NULL,
[nationnalite] NVARCHAR (MAX) NULL,
[telephone1] NVARCHAR (MAX) NULL,
[telephone2] NVARCHAR (MAX) NULL,
[classe] NVARCHAR (MAX) NULL,
[remarque] NVARCHAR (MAX) NULL,
[nom_mere] NVARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([matricule] ASC)
the error is :
System.Data.SqlClient.SqlException : 'Conversion failed when converting the varchar value 'Rechercher' to data type int.'