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();
}
}
dies ist mein Code und dies auf einen Fehler machen, dass:Wie kann ich eine String-Variable in einer Abfrage aufrufen?
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 Tabellenstruktur:
Was ist der Wert von 'tblName'? –
was ist der Wert von COLUMN_TABLE_NAME && TABLE_NAME –
Tblname aktualisiert als Feldwert von Tabellenname ist hier college1 ;. Der Wert von COLUMN_TABLE_NAME && TABLE_NAME ist college1 und das entsprechende Datum –