Caused by: android.database.sqlite.SQLiteException: no such column: kia (code 1): , while compiling: UPDATE people_chat SET msg = kia WHERE name = uol
final String CREATE_QUERY4 = "CREATE TABLE IF NOT EXISTS "+PEOPLE_CHAT+ "("+ "id INTEGER primary key autoincrement,"+ "name TEXT NOT NULL ,"+ "msg TEXT NOT NULL "+ ")";
List item
列表项
public void upDateMsg(String name,String msg){
Log.i(TAG, "UpdateData: "+msg);
String strSQL = "UPDATE people_chat SET msg = "+msg+" WHERE name = "+ name;
db.execSQL(strSQL);
Log.i(TAG, "Update Success: "+strSQL);
}
}
1 个解决方案
#1
0
It should be:
应该是:
UPDATE people_chat SET msg = 'kia' WHERE name = 'uol'
You are missing single quotes. Change code to:
你缺少单引号。改变代码:
String strSQL = "UPDATE people_chat SET msg = '"+msg+"' WHERE name = '"+ name+"'";
Note: As pointed out in comments, If name contains single quotes, then the query would fail. It must be escaped accordingly.
注:如注释中所指出的,如果名称包含单引号,则查询将失败。它必须被相应地逃脱。
#1
0
It should be:
应该是:
UPDATE people_chat SET msg = 'kia' WHERE name = 'uol'
You are missing single quotes. Change code to:
你缺少单引号。改变代码:
String strSQL = "UPDATE people_chat SET msg = '"+msg+"' WHERE name = '"+ name+"'";
Note: As pointed out in comments, If name contains single quotes, then the query would fail. It must be escaped accordingly.
注:如注释中所指出的,如果名称包含单引号,则查询将失败。它必须被相应地逃脱。