0
public void savedate(String tblname,String time)
{
ContentValues values = new ContentValues();
values.put(COLUMN_TABLE_NAME, tblname);
values.put(COLUMN_TIME, time);
String count ="select "+COLUMN_TABLE_NAME+" from "+TABLE_NAME+" where "+COLUMN_TABLE_NAME+ tblname;
Cursor mcursor = db.rawQuery(count, null);
if(mcursor.getCount()>0)
{
long s = db.update(TABLE_NAME, values, COLUMN_TIME + "=? ", new String[]{time});
if (s != -1)
Toast.makeText(context, "updated, row id: " + s, Toast.LENGTH_SHORT).show();
else
Toast.makeText(context, "no change", Toast.LENGTH_SHORT).show();
}
else
{
long s=db.insert(TABLE_NAME, null, values);
if(s != -1)
Toast.makeText(context, "inserted, row id: " + s, Toast.LENGTH_SHORT).show();
else
Toast.makeText(context, "no_change", Toast.LENGTH_SHORT).show();
}
}
這是我的代碼,這使一個錯誤:如何在查詢中調用字符串變體?
06-20 11:09:52.258 2001-2348/com.example.mytest.syncapp E/SQLiteLog﹕ (1) no such column: college1
06-20 11:09:52.260 2001-2348/com.example.mytest.syncapp E/Webservice 1﹕ android.database.sqlite.SQLiteException: no such column: college1 (code 1): , while compiling: select table_name from datesync where table_name= college1
SQLite表結構:
'tblName'的值是什麼? –
COLUMN_TABLE_NAME && TABLE_NAME的值是什麼? –
tblname refres作爲table_name的字段值,這裏是college1 ;. COLUMN_TABLE_NAME && TABLE_NAME的值是college1和相應的日期 –