public void addFBComments(int id){
sqliteDatabase db = this.getWritableDatabase();
String query = "UPDATE " + TABLE_FB_Feed + " SET " + COL_FB_COMMENTS+"="+"HELLO" + " WHERE " + COL_FB_ID+"="+id;
db.execsql(query);
}
当我运行该命令时,它会抛出此错误:
08-18 15:42:10.145: E/AndroidRuntime(10493): FATAL EXCEPTION: Thread-922
08-18 15:42:10.145: E/AndroidRuntime(10493): android.database.sqlite.sqliteException: no such column: HELLO (code 1): , while compiling: UPDATE fb_Feed SET fb_comments= HELLO WHERE _id=3
这是TABLE_FB_Feed:
private static final String TABLE_FB_Feed_CREATE = "create table " + TABLE_FB_Feed +
" ("
+ COL_FB_ID + " integer primary key autoincrement not null,"
+ COL_FB_MESSAGE + " text,"
+ COL_FB_CAPTION + " text,"
+ COL_FB_POSTER_ID + " text,"
+ COL_FB_POST_ID + " text,"
+ COL_FB_LIKES + " text,"
+ COL_FB_POSTER_NAME + " text,"
+ COL_FB_COMMENTS + " text," // this is the column i want to update
+ COL_FB_LIKES_NUM + " text,"
+ COL_FB_TIMESTAMP + " text,"
+ COL_FB_PROFILE_PICTURE_URI + " text,"
+ COL_FB_PICTURE_URI + " text,"
+ COL_FB_NAME + " text,"
+ COL_FB_PREVIoUS_PAGE_URI + " text,"
+ COL_FB_NEXT_PAGE_URI + " text,"
+ COL_FB_POST_TYPE + " text,"
+ COL_FB_LINK_NAME + " text,"
+ COL_FB_COMMENTS_NUM + " text,"
+ COL_FB_STORY + " text,"
+ COL_FB_DESCRIPTION + " text,"
+ COL_FB_COMMENTS_BEFORE + " text,"
+ COL_FB_COMMENTS_AFTER + " text,"
+ COL_FB_LIKES_PROFILE_PIC + " text,"
+ COL_FB_COMMENTS_PROFILE_PIC + " text);";
为什么抛出查询?我以为我正在做的一切都正确.
解决方法:
String query = "UPDATE " + TABLE_FB_Feed + " SET " + COL_FB_COMMENTS
+"="+"'HELLO'" + " WHERE " + COL_FB_ID+"="+id
要么
String query = "UPDATE " + TABLE_FB_Feed + " SET " + COL_FB_COMMENTS
+"='HELLO' WHERE " + COL_FB_ID+"="+id
这是另一个例子
"UPDATE DB_TABLE SET YOUR_COLUMN='newValue' WHERE id=myidValue");
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。