【发布时间】:2017-02-01 04:16:29
【问题描述】:
我知道它已经被问了一百万次,但我仍然无法让它工作。我正在尝试从我的 sqlite 数据库中删除一行,但我不断收到错误消息。我确定这与我的语法有关,但我无法获得正确的语法。
这是我的删除方法
public void deleteRouteNote(int notePosition){
SQLiteDatabase db = getWritableDatabase();
db.delete(TABLE_ROUTE_NOTE, COLUMN_NOTE + COLUMN_ROUTE_NOTE_POSITION + "where" + COLUMN_ROUTE_NOTE_POSITION + "=" + notePosition, null);
db.close();
我遇到的错误
android.database.sqlite.SQLiteException: no such column: routeNotewhererouteNotePosition (code 1): , while compiling: DELETE FROM route_note WHERE routeNotewhererouteNotePosition=9
感谢您的帮助!!
编辑:
这是我插入数据的方式
/////Add route note row to table
public void addRouteNote(RouteNote routeNote){
ContentValues values = new ContentValues();
values.put(COLUMN_NOTE, routeNote.get_routeNote());
values.put(COLUMN_ROUTE_NOTE_POSITION, routeNote.get_routeNotePosition());
SQLiteDatabase db = getWritableDatabase();
db.insertWithOnConflict(TABLE_ROUTE_NOTE , null, values, SQLiteDatabase.CONFLICT_REPLACE);
db.close();
}
【问题讨论】:
-
请检查您是否有列
routeNotewhererouteNotePosition存在且sql 是否正确。请在此处发布 sql。 -
我编辑了我的原始帖子,以展示我如何插入效果很好。
标签: android sqlite sql-delete