dimanche 7 juin 2015

Keep getting SQLiteException no such column

I'm trying to update a particular row of a database, and I have the following code

 public String CREATE_QUERY = "CREATE TABLE " + TableData.TableInfo.TABLE_NAME +
        "(" + TableData.TableInfo.USER_NAME + " TEXT, " + TableData.TableInfo.USER_PIN +
        " TEXT, " + TableData.TableInfo.PARTNER_FIRST + " Text, " + TableData.TableInfo.PARTNER_SECOND +
        " TEXT, " + TableData.TableInfo.DATE + " TEXT, " + TableData.TableInfo.SIGNATURE_IMAGE + " BLOB, " +
        TableData.TableInfo.PARTNER_SIGNATURE + " BLOB);";

And I am getting an error from

ContentValues cv = new ContentValues();
    DatabaseOperations DOP = new DatabaseOperations(ctx);
    Cursor CR = DOP.getInformation(DOP);
    CR.moveToLast();

    SQLiteDatabase SQ = DOP.getWritableDatabase();

    ContentValues args = new ContentValues();
    args.put(TableData.TableInfo.USER_NAME, CR.getString(0));
    args.put(TableData.TableInfo.PARTNER_FIRST, partner_name);


    SQ.update(TableData.TableInfo.TABLE_NAME, args, "ROWID=?" + id, null);

This is the error:

     Caused by: android.database.sqlite.SQLiteException: no such column: partner_first (code 1): , while compiling: UPDATE reg_info SET user_name=?,partner_first=? WHERE ROWID=?54

Here is my table info

public static abstract class TableInfo implements BaseColumns {

    public static final String USER_NAME = "user_name";
    public static final String USER_PIN = "user_pin";
    public static final String PARTNER_FIRST = "partner_first";
    public static final String PARTNER_SECOND = "partner_second";
    public static final String DATE = "date";
    //public static final String LOC = "location";
    public static final String SIGNATURE_IMAGE = "signature_image";
    public static final String PARTNER_SIGNATURE = "partner_signature";
    public static final String DATABASE_NAME = "user_info";
    public static final String TABLE_NAME = "reg_info";

}

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire