mardi 2 février 2016

INSERT Row in SQLite database by C#

I tried to insert a row in SQLite database but there is an exception. I have searched but I didn't found anything about it.

 string query = "INSERT INTO Goods (IDnumber, Name, DPrice, SPrice, num, IDorder) "
            + "VALUES (@II, @NN, @DP, @SP, @NA, '0', @I1)";

                    using (SQLiteConnection connection = new SQLiteConnection(connectionString))
                    using (SQLiteCommand command = new SQLiteCommand(query, connection))
                    {
                        connection.Open();
                        int i1 = int.Parse(textBox2.Text);
                        command.Parameters.Add(new SQLiteParameter ("@II", textBox2.Text));
                        command.Parameters.Add(new SQLiteParameter("@NN", textBox1.Text));
                        command.Parameters.Add(new SQLiteParameter("@DP", dp.ToString()));
                        command.Parameters.Add(new SQLiteParameter("@SP", sp.ToString()));

                        command.Parameters.Add(new SQLiteParameter("@NA", am.ToString()));
                        command.Parameters.Add(new SQLiteParameter ("@I1",i1.ToString()));

                        command.ExecuteNonQuery();

That's the code and the exception is below:

An unhandled exception of type 'System.Data.SQLite.SQLiteException' occurred in System.Data.SQLite.dll Additional information: SQLite error

What should I do ?

Aucun commentaire:

Enregistrer un commentaire