0
I’m trying to insert records with auto increment, but every time I get failure return. But if it’s auto increment he shouldn’t ask me for the fifth record?
Database code:
database1.execSQL("CREATE TABLE IF NOT EXISTS ssxx (idEvento INTEGER
PRIMARY KEY AUTOINCREMENT, data varchar(20),valor
varchar(20),descricao varchar(20),forma varchar(20));");
Functional Inclusion Code:
database1.execSQL("INSERT INTO ssxx VALUES('" + EDNome.getText() +
"','" + EDFone.getText() + "','" + EDesc.getText() + "','" +
radioButton.getText() + "')");
The Error:
android.database.sqlite.SQLiteException: table ssxx has 5 columns but 4 values were supplied (code 1 SQLITE_ERROR): , while compiling: INSERT INTO ssxx VALUES('05/07/2019','11','q','Vista')
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
He says I’m trying to enter 4 records, but my database has 5 fields. Auto increment should not automatically fill in id field?
If you want a field to be included with its DEFAULT value then this field cannot appear in the field list. In your case you need to put the list of fields for which you are reporting values. See the documentation.
– anonimo