我在其他项目的 SQLite 数据库表中进行了更新,它工作正常,在这种情况下,一切似乎都很好,但显示错误。这是更新表的代码:
public void updateNamePhone(ArrayList<String> seekerList, ArrayList<String> nameList, ArrayList<String> phoneList) {
// TODO Auto-generated method stub
try{
for(int i=0;i<seekerList.size();i++){
ContentValues editCon = new ContentValues();
editCon.put(KEY_NAME, nameList.get(i));
editCon.put(KEY_PHONE, phoneList.get(i));
ourDatabase.update(DATABASE_TABLE, editCon, KEY_REGID+"="+seekerList.get(i), null);
}
}catch(Exception e){
System.out.println(e.getMessage());
}
}
三个数组列表是:
seekerList:[Chandigarh, Mohali, Panchkula, Ambala]
nameList:[Vikram, Ashish, Rohit, Sunny]
phonelist:[989,98763,564838,33224]
所有表格列在创建时都是文本类型。
这是捕获的错误:
05-01 09:08:11.234: E/Database(25886): updateWithOnConflict |Error updating table = seekersList
05-01 09:08:11.234: I/System.out(25886): no such column: Chandigarh: , while compiling: UPDATE seekersList SET person_phone=?, person_name=? WHERE person_regid=Chandigarh