Problème d'INSERT avec SqlCommand.
Bonjour,
Je rencontre un problème auquel je ne trouve pas de solution. J'ai beau cherché mais je trouve pas l'erreur: je voudrais simplement faire un INSERT dans ma base de données en utilisant un SqlCommand comme ceci:
Code:
1 2 3 4 5 6 7
| System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.Open()
cmd.CommandText = "INSERT INTO AppHisto.dbo.Print (Imp_Sonde1, Imp_Sonde2, Imp_Sonde3, ...) VALUES ('" + s1 + "', '" + s2 + "', '" + s3 + "', ...)";
cmd.ExecuteNonQuery();
conn.Close(); |
s1, s2, s3, ... sont des variables de type string.
Mais je rencontre un message d'erreur qui dit:
Citation:
Incorrect syntax near the keyword 'Print'.
The name "Imp_Sonde1" is not permitted in this context. Valid expressions are constants constants expressions, and (in some contexts) variables. Colum names are not permitted.
Auriez-vous une idée ce qui pose problème?
Merci d'avance