java - "No such column" when running update on SQLite -
i'm trying update row in database. here code trying use update:
public void addfbcomments(int id){ sqlitedatabase db = this.getwritabledatabase(); string query = "update " + table_fb_feed + " set " + col_fb_comments+"="+"hello" + " " + col_fb_id+"="+id; db.execsql(query); }
when run command, throws error:
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 _id=3
here 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," // column want 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);";
why throwing query? thought doing correctly.
in code need add single quotes:
string query = "update " + table_fb_feed + " set " + col_fb_comments +"="+"'hello'" + " " + col_fb_id+"="+id
or
string query = "update " + table_fb_feed + " set " + col_fb_comments +"='hello' " + col_fb_id+"="+id
this example
"update db_table set your_column='newvalue' id=myidvalue");
Comments
Post a Comment