我的UpdateRow
函数不起作用。有人可以帮忙吗?
public boolean UpdateRow(String date ,String timeOut) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_NAME + " SET " + COL_3 + "=" + timeOut + "WHERE " + COL_1 + "=" + date);
}
谢谢。
答案 0 :(得分:0)
我认为您编写的查询缺少WHERE
子句和COL_1
之间的空格。该行应编写如下。
db.execSQL("UPDATE " + TABLE_NAME
+ " SET " + COL_3 + " = " + timeOut
+ " WHERE " + COL_1 + " = " + date
);
答案 1 :(得分:0)
date
前后的撇号和列之间的间隔:
db.execSQL("UPDATE " + TABLE_NAME + " SET " + COL_3 + "=" + timeOut + " WHERE " + COL_1 + "='" + date + "'");
如果timeOut
是TEXT
,那么它也需要加撇号:
db.execSQL("UPDATE " + TABLE_NAME + " SET " + COL_3 + "='" + timeOut + "' WHERE " + COL_1 + "='" + date + "'");