I am facing a problem in updating a table with multiple columns in where clause of the db.update
in sqlite.
Below is what I have tried but not accepting and showing syntax error.
db.getWritableDatabase().update(tablename, update((buy+dupbuy)), (column2+"=? and"+ column3+"=?"),(new String[] {getdate}+" and"+new String[] {stockname}));
In above query
but giving syntax error
The method update(String, ContentValues, String, String[]) in the type SQLiteDatabase is not applicable for the arguments (String, ContentValues, String, String)
How can I declare multiple columns in where clause?
Try changing
db.getWritableDatabase().update(tablename, update((buy+dupbuy)), (column2+"=? and"+ column3+"=?"),(new String[] {getdate}+" and"+new String[] {stockname}));
to
db.getWritableDatabase().update(tablename, update((buy+dupbuy)), (column2+"=? and "+ column3+"=?"),(new String[] {getdate,stockname}));
Add a space after the "and"
in the WHERE
clause and you need to pass a String[]
and not String
in the whereArgs
parameter. Currently you are passing a String