更新数据时出错。错误是:
android.database.sqlite.SQLiteException:near" parth":语法错误 (代码1):,编译时:UPDATE收入SET income_balance =?哪里 income_name =?PARTH
public void update2( String name, String bal){
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
//values.put(INCOME_NAME, name);
values.put(INCOME_BALANCE, bal);
db.update(TABLE_INCOME, values, INCOME_NAME+"=?"+name, new String[]{String.valueOf(name)});
答案 0 :(得分:0)
将INCOME_NAME+"=?"+name
替换为INCOME_NAME+"=?"
(不使用+name
,您将此值设置为new String[]{String.valueOf(name)}
行)
db.update(TABLE_INCOME, values, INCOME_NAME+"=?", new String[]{String.valueOf(name)});
或最终
db.update(TABLE_INCOME, values, INCOME_NAME+"='"+name+"'", null);