Android SQLite更新查询不工作?
我收到了这个错误消息。你能指出罪犯吗Android SQLite更新查询不工作?,android,sqlite,Android,Sqlite,我收到了这个错误消息。你能指出罪犯吗 public void AddViewCount(String chname) { String selectQuery = "UPDATE channel_login SET TimesViewed=TimesViewed+1 WHERE channelName="+chname ; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(s
public void AddViewCount(String chname)
{
String selectQuery = "UPDATE channel_login SET TimesViewed=TimesViewed+1 WHERE channelName="+chname ;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
System.out.print("Count"+cursor.getCount());
}
请尝试以下操作:
android.database.sqlite.SQLiteException: no such column: Sat1
(code 1):,while compiling: UPDATE channel_login SET
TimesViewed=TimesViewed+1 WHERE channelName=Sat1
在文本值周围添加“”应该有效。另外,除非您需要游标计数,否则您可以使用db.execSQL(selectQuery)代码>以执行更新
public void AddViewCount(String chname)
{
String selectQuery = "UPDATE channel_login SET TimesViewed=TimesViewed+1 WHERE channelName='"+chname+"'";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
System.out.print("Count"+cursor.getCount());
}