I am trying to update timestamp everytime I update the row in sqlite.I tried the code below and crashes at :
android.database.sqlite.SQLiteException: near "05": syntax error (code 1): , while compiling: UPDATE databasetable3 SET Stats = 1 ,timestamp = 2015/01/07 05:27:56 WHERE No = 2
:
String CREATE_TABLE3 = "CREATE TABLE IF NOT EXISTS " + databasetable3 + "("+ KEY_sno + " INTEGER PRIMARY KEY, " + KEY_Stats+ " VARCHAR, " + KEY_No+ " VARCHAR , " + "timestamp"+ " TIMESTAMP DEFAULT CURRENT_TIMESTAMP)";
db.execSQL(CREATE_TABLE3);
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
ourdatabase.execSQL("UPDATE databasetable3 SET Stats = "+Stats+" ,timestamp = "+dateFormat.format(date)+" WHERE No = "+no);
Aucun commentaire:
Enregistrer un commentaire