SQL语句包含表中没有的字段,报错no such column:
Android 2.3.3 Eclipse Version: 3.7.0 Console
?LogCat? 报错信息:
02-23 11:20:41.360: ERROR/AndroidRuntime(4366): android.database.sqlite.SQLiteException: no such column: iphone: , while compiling: SELECT * FROM Mobile WHERE iphone=? and status=102-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteiphone.<init>(SQLiteiphone.java:83)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1235)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1189)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1271)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at com.tmall.nokia.db.MobileDBHelper.find_Iphone(MobileDBHelper.java:55)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at com.tmall.nokia.MobileDBopt.find_Iphone(MobileDBopt.java:154)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at com.tmall.nokia.manage.Mobile.startImport(Mobile.java:175)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at com.tmall.nokia.manage.Mobile$3.run(Mobile.java:117)02-23 11:20:41.360: ERROR/AndroidRuntime(4366):???? at java.lang.Thread.run(Thread.java:1019)
?
主要错误:
02-23 11:20:41.360: ERROR/AndroidRuntime(4366): android.database.sqlite.SQLiteException: no such column: iphone: , while compiling: SELECT * FROM Mobile WHERE iphone=? and status=1
?
?
发生错误原因分析:
从Mobile表中查询iphone时,发现数据库的Mobile表中没有iphone这一列。检查创建数据库表的代码,发现在建Mobile表时,确实没有iphone字段。
?
解决办法:
在创建数据库的Mobile表时添加iphone列。