pb ajout ds BD sqlserver 2005
bonjour,
je développe une application windows .NET avec c#,
je met le code suivant pour la selection de la BD sqlserver 2005
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| SqlConnection maConnection = new SqlConnection(connectionString);
maConnection.Open();
SqlCommand maCommand = maConnection.CreateCommand();
maCommand.CommandText = "select Login, n_ambulance, Nom, Prenom, tel from tab_ambulancier";
SqlDataAdapter monAdapter = new SqlDataAdapter();
monAdapter.SelectCommand = maCommand;
DataSet monDataSet = new DataSet();
monAdapter.Fill(monDataSet, "ListeAmbulancier");
maConnection.Close(); |
ça marche nickel.
mon pb c ds l'ajout, j'utilise le mêm code sauf que bien évedemment je change la requete et g met monAdapter.InsertCommand, mais ça donne rien
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
SqlConnection maConnection = new SqlConnection(Properties.Settings.Default.chaineConnection);
maConnection.Open();
SqlCommand maCommand = maConnection.CreateCommand();
maCommand.CommandText = "insert into tab_ambulancier values('login2','pass','n_ambulance','nom','prenom',null)";
maCommand.CommandType = CommandType.Text;
SqlDataAdapter monAdapter = new SqlDataAdapter();
monAdapter.InsertCommand = maCommand;
maConnection.Close(); |
est-ce que je ss dans la bonne voix pour l'ajout?? ou bien il ya d'autres classes à appeler
merci pour votre aide