Question

Je viens d'apprendre SQLite et je ne parviens pas à compiler correctement mes paramètres dans la commande. Quand j'exécute le code suivant:

this.command.CommandText = "INSERT INTO [StringData] VALUE (?,?)";

this.data = new SQLiteParameter();
this.byteIndex = new SQLiteParameter();

this.command.Parameters.Add(this.data);
this.command.Parameters.Add(this.byteIndex);

this.data.Value = data.Data;
this.byteIndex.Value = data.ByteIndex;

this.command.ExecuteNonQuery();

Je reçois une exception SQLite. En inspectant le CommandText, je découvre que quoi que je fasse, ce n'est pas correctement que j'ajoute les paramètres: INSERT INTO [StringData] VALEUR (?,?)

Avez-vous des idées qui me manquent?

Merci

Était-ce utile?

La solution

Essayez VALUES au lieu de VALUE .

Autres conseils

Essayez une approche différente en nommant vos champs dans la requête et en nommant les paramètres dans la requête:

this.command.CommandText = "INSERT INTO StringData (field1, field2) VALUES(@param1, @param2)";
this.command.CommandType = CommandType.Text;
this.command.Parameters.Add(new SQLiteParameter("@param1", data.Data));
this.command.Parameters.Add(new SQLiteParameter("@param2", data.ByteIndex));
...
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top