在表中没有这样的列

时间:2013-07-13 09:27:56

标签: android sqlite

获取异常没有这样的列但实际上列数据存在于数据库中我无法捕获该异常可以任何人帮助我

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)

1 个答案:

答案 0 :(得分:2)

在sqlite for where子句中你需要在搜索字符串周围使用撇号。所以你的查询应该是

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

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