这是我的桌子
db.execSQL("CREATE TABLE tbl_groupAccount ( \n" +
" ID INTEGER PRIMARY KEY AUTOINCREMENT\n" +
" NOT NULL\n" +
" UNIQUE,\n" +
" ACCOUNT_GROUP_NAME VARCHAR,\n" +
" ACCOUNT_GROUP_TYPE VARCHAR \n" +
");");
并且我用它来将数据更新到表中
public boolean updateAccountGroup(String nameAccountGroup,String groupAccountType, Integer id) {
boolean result;
String sql = "UPDATE tbl_groupAccount" +
" SET ACCOUNT_GROUP_NAME , ACCOUNT_GROUP_TYPE = '" + nameAccountGroup + groupAccountType + "'" +
"WHERE ID = " + id;
try {
SQLiteDatabase database = this.getWritableDatabase();
database.execSQL(sql);
database.close();
result = true;
} catch (Exception ex) {
result = false;
}
return result;
}
当我单击按钮以将数据更新到表中时,什么也没有发生。并且没有错误发生。并没有更新到表中。有人可以帮助我。请
谢谢
您的更新SQL应该像:
String sql = "UPDATE tbl_groupAccount" +
" SET ACCOUNT_GROUP_NAME = '" + nameAccountGroup + "' , ACCOUNT_GROUP_TYPE ='"+ groupAccountType + "'" +
" WHERE ID = " + id;