Android Sqllite: Unable to resolve syntax error in request

I am updating the cart on each tab, in the code I am updating the cart item but showing an error in the syntax.

 ContentValues values = new ContentValues();
    DbHelper dbHelper = new DbHelper(context);

    SQLiteDatabase database;
    database=  dbHelper.getWritableDatabase();

    values.put(DbConstants.COLUMN_MEMBER, cartItemBean.getCOLUMN_MEMBER());
    values.put(DbConstants.COLUMN_DATE, cartItemBean.getCOLUMN_DATE());
    values.put(DbConstants.COLUMN_TIME, cartItemBean.getCOLUMN_TIME());

    String sql2 = "UPDATE " + DbConstants.TABLE_CART + " SET " +
            DbConstants.COLUMN_MEMBER + " = '" + cartItemBean.getCOLUMN_MEMBER() + "' AND "
            + DbConstants.COLUMN_DATE + " = '" + cartItemBean.getCOLUMN_DATE() + "' AND "
            + DbConstants.COLUMN_TIME + " = '" + cartItemBean.getCOLUMN_TIME() + "' AND "
            + DbConstants.COLUMN_TOTAL_PRICE + " = '" + cartItemBean.getCOLUMN_TOTAL_PRICE() + "' AND "
            + "' WHERE " +
            DbConstants.COLUMN_PACKID + " = '" + cartItemBean.getCOLUMN_PACKID() + "' AND "
            + DbConstants.COLUMN_USERID + " = '" + cartItemBean.getCOLUMN_USERID() + "'";

     database.execSQL(sql2);

      

+3


source to share


1 answer


You added AND

instead comma

, removing which will fix the problem.

Change your query to:



String sql2 = "UPDATE " + DbConstants.TABLE_CART + " SET " +
        DbConstants.COLUMN_MEMBER + " = '" + cartItemBean.getCOLUMN_MEMBER() + "', "
        + DbConstants.COLUMN_DATE + " = '" + cartItemBean.getCOLUMN_DATE() + "', "
        + DbConstants.COLUMN_TIME + " = '" + cartItemBean.getCOLUMN_TIME() + "', "
        + DbConstants.COLUMN_TOTAL_PRICE + " = '" + cartItemBean.getCOLUMN_TOTAL_PRICE() + "' "
        + " WHERE " +
        DbConstants.COLUMN_PACKID + " = '" + cartItemBean.getCOLUMN_PACKID() + "' AND "
        + DbConstants.COLUMN_USERID + " = '" + cartItemBean.getCOLUMN_USERID() + "'";

      

Check out the sample in the tutorial .

+4


source







All Articles