Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SQLite更新查询不工作?_Android_Sqlite - Fatal编程技术网

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());  

}