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
最佳答案
请尝试以下操作:
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());
}
在文本值周围添加“”应该可以。另外,除非需要游标计数,否则可以使用
db.execSQL(selectQuery);
进行更新。