我无法弄清楚为什么删除查询无法识别该列。我尝试了各种方法,但是当代码运行时,我不断收到错误:
" ...没有这样的专栏:expense.expId"
表已经创建,我可以向他们添加数据,相关代码将被发布:
这些字符串在类DbHelper
中定义public static final String TABLE_EXPENSE="expense";
public static final String EXPENSE_ID="expId";
public static final String EXPENSE_AMT="amt";
public static final String EXPENSE_DATE="edate";
创建表
public static void createExp(DbHelper dbh,SQLiteDatabase db){
String code="create table "+dbh.TABLE_EXPENSE+"("
+dbh.EXPENSE_ID+" integer primary key autoincrement,"
+dbh.EXPENSE_AMT+" double,"
+dbh.EXPENSE_DATE+" TIMESTAMP DEFAULT CURRENT_TIMESTAMP);";
db.execSQL(code);
}
查询版本1:
db.delete("expense","expId="+i,null);
版本2:
public static void deleteExp(DbHelper dbh,SQLiteDatabase db,int i){
String code="delete from "+dbh.TABLE_EXPENSE+" where "+dbh.EXPENSE_ID+"="+i+";";
db.rawQuery(code,null);
}
版本3:
public static void deleteExp(DbHelper dbh,SQLiteDatabase db,int i){
String code="delete from expense where expId="+i+";";
db.rawQuery(code,null);
}
所有这些都产生了上面提到的相同错误