2016-12-24 125 views
0

我正在Android中使用Sqlite實現更改密碼。Android更新查詢錯誤

我的查詢是:

try 
{ 
    String update_query = "UPDATE " + TABLE_NAME + " SET " + PWD + "='" + temp_new_pwd + "' WHERE " + EMAIL + " = " + email; 
    db.execSQL(update_query); 
    Toast.makeText(getApplicationContext(), "Password Changed Successfully", Toast.LENGTH_SHORT).show(); 
} 
catch(Exception e) 
{ 
    Toast.makeText(getApplicationContext(), "Database Error", Toast.LENGTH_SHORT).show(); 
} 

它顯示以下錯誤:

E/SQLiteLog: (1) near "@abc": syntax error 
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa29113f0 

回答

0

嘗試此更新記錄

ourDatabase = ourHelper.getWritableDatabase(); 
ContentValues values = new ContentValues(); 
values.put(PWD, new_pwd); 
ourDatabase.update(DATABASE_TABLE, values, EMAIL + "=?", new String[]{email}); 
+0

不工作表演: 'W/OpenGLRenderer:無法設置EGL_SWAP_BEHAVIOR上表面0xaa410c60,誤差= EGL_SUCCESS E /表面:getSlotFromBufferLocked:未知緩衝液:0xaa005100' – Sagar

0

嘗試此更新記錄 希望它的工作很好...

public void updateQuantity(int id, int quantity) { if (quantity == 0) 
     deleteItem(id); 
    else { 

     SQLiteDatabase db = this.getWritableDatabase(); 
     ContentValues values = new ContentValues(); 
     values.put(Constants.QUANTITY, quantity); 
     values.put(Constants.DATE_NAME, String.valueOf(new DateTime())); 
     int i = db.update(Constants.TABLE_NAME, values, Constants.KEY_ID + " = " + id, null); 
    } 
}