lundi 29 juin 2015

SQLite Android No such Column Error

I'm trying to use SQLite in android but for some reason I'm getting the no such column error. I think the error may be syntax but I can't seem to locate it.

This is my code:

         @Override
    public void onCreate(SQLiteDatabase database)
    {
        database.execSQL("create table " +
                TABLE_NAME +
                " (" +
                TABLE_ROW_ID + " integer primary key autoincrement not null," +
                TABLE_ROW_ONE + " text," +
                TABLE_ROW_TWO + " text," +
                TABLE_ROW_THREE +  " text," +
                TABLE_ROW_FOUR + " text" +
                ");");
    }

I had tried some formatting tricks like adding a space to the fourth text, or subtracting one but none of them seemed to have worked yet.

Beneath is the logcat reading.

 android.database.sqlite.SQLiteException: table database_table has no column named table_row_three (code 1): , while compiling: INSERT INTO database_table(table_row_three,table_row_two,table_row_four,table_row_one) VALUES (?,?,?,?)
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:892)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:503)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
        at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1568)
        at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1440)

Thank you!

Aucun commentaire:

Enregistrer un commentaire