0

得到一个异常没有这样的列但实际上列数据存在于数据库中我无法捕捉到该异常任何人都可以帮助我

07-13 09:17:41.720: E/SQLiteLog(16717): (1) near "Yongming": syntax error
07-13 09:17:41.720: D/AndroidRuntime(16717): Shutting down VM
07-13 09:17:41.730: W/dalvikvm(16717): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
07-13 09:17:41.750: E/AndroidRuntime(16717): FATAL EXCEPTION: main
07-13 09:17:41.750: E/AndroidRuntime(16717): android.database.sqlite.SQLiteException: near "Yongming": syntax error (code 1): , while compiling: DELETE FROM Exhibitors_Bookmark_table WHERE Exhibitor_data=Shanghai Yongming Electronics Co.,LTD.
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at android.database.sqlite.SQLiteDatabase.delete(SQLiteDatabase.java:1491)
07-13 09:17:41.750: E/AndroidRuntime(16717):    at datahandler.FavoratesDB.delete_exhibitor_name(FavoratesDB.java:156)
4

1 回答 1

2

在 sqlite 的 where 子句中,您需要在搜索字符串周围使用撇号。所以你的查询应该看起来像

DELETE FROM Exhibitors_Bookmark_table WHERE Exhibitor_data='Shanghai Yongming Electronics Co.,LTD.'

可能这就是没有得到的原因。

于 2013-07-13T09:30:53.727 回答