您好,那些3“PE_ ..”我首先在创建时添加值,并且那些3“et .._ getText()。toString()..”由用户获取新的更改。你明白了吗?仍然我的应用程序停止,因为我在db下面调用update方法:
controller.update_pw(PE_Desc, PE_Pass, PE_Note, etDesc.getText().toString(), etPass.getText().toString(), etNote.getText().toString());
这是我在我的数据库上的更新方法:
public void update_pw(String old_description, String old_password, String old_note, String new_description, String new_password, String new_note){
this.getWritableDatabase().execSQL("UPDATE PASSWALL SET PW_DESC='"+new_description+"', PW_PASS='"+new_password+"', PW_NOTE='"+new_note+"' " +
"WHERE PW_DESC='"+old_description+"', PW_PASS='"+old_password+"', PW_NOTE='"+old_note+"'");
我想知道“PW_DESC ='',PW_PASS ='',PW_NOTE =''WHERE ...”之间的逗号,这是正确的吗?需要帮助,感谢您的建议。谢谢!
答案 0 :(得分:0)
您在 WHERE 子句中缺少 AND 条件必须由 AND 运算符分隔。
<强>编辑:强> 更新值的另一种方法。
ContentValues newValues = new ContentValues();
newValues.put("PW_DESC", new_description);
newValues.put("PW_PASS", new_password);
newValues.put("PW_NOTE", new_note);
SQLiteDatabase db=getReadableDatabase();
db.update("PASSWALL", newValues, "PW_DESC= '" + old_description + "' AND "+"PW_PASS= '" +old_password+ "' AND "+ "PW_NOTE= '" + old_note+ "'", null);
答案 1 :(得分:0)
试试这个,
public void update_pw(String old_description, String old_password, String old_note, String new_description, String new_password, String new_note) {
SQLiteDatabase db = this.getWritableDatabase();
String strSQL = "UPDATE PASSWALL SET PW_DESC='" + new_description + "', PW_PASS='" + new_password + "', PW_NOTE='" + new_note + "' WHERE PW_DESC='" + old_description + "' AND PW_PASS='" + old_password + "' AND PW_NOTE='" + old_note + "'";
db.execSQL(strSQL);
}