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表结构:
答案 0 :(得分:0)
最后执行此代码......
String count =“select”+ COLUMN_TABLE_NAME +“from”+ TABLE_NAME +“where”+ COLUMN_TABLE_NAME +“='”+ tblname +“'”;
Cursor mcursor = db.rawQuery(count, null);