以下行显示错误为“SET”附近的sytax错误
db.update( TABLE_SECOND_NAME,cv, " SET " + COL_SECOND_2 + "= ( CONCAT
"+ (COL_SECOND_3+ ", " +name)+ "'ROLL=?",new String[]{roll});
我希望在更新期间保持旧值和新值两者。第一个值已经存储,而新值正在更新。 日志为:
09-29 14:20:37.021 27122-27122/com.example.prince.studentrecord
E/ViewRootImpl: sendUserActionEvent() mView == null
09-29 14:20:37.581 27122-27122/com.example.prince.studentrecord
ViewPostImeInputStage ACTION_DOWN
09-29 14:20:38.941 27122-27122/com.example.prince.studentrecord
D/ViewRootImpl:
09-29 14:20:39.231 27122-27122/com.example.prince.studentrecord
E/ViewRootImpl: sendUserActionEvent() mView == null
09-29 14:20:42.061 27122-27122/com.example.prince.studentrecord
09-29 14:20:42.161 27122-27122/com.example.prince.studentrecord
E/SQLiteLog: (1) near "SET": syntax error
答案 0 :(得分:0)
将这些方法用于sqlite数据库的更新表:
public int updateContact(联系联系人){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, contact.getName());
values.put(KEY_PH_NO, contact.getPhoneNumber());
// updating row
return db.update(TABLE_CONTACTS, values, KEY_ID + " = ?",
new String[] { String.valueOf(contact.getID()) });
}