Cursor cursor = db.query(UserTable, null,
"UserName=?", new String[] {username},
null, null, AccessedDate);
当我试图打开我的活动时,我得到这个没有发现列的异常。错误指向上述query line
。
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.text.sample/com.text.sample.usercontext.RecentsActivity}: android.database.sqlite.SQLiteException: no such column: UserName (code 1): , while compile : SELECT * FROM Patient WHERE UserName=? ORDER BY AccessedDate at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app .ActivityThread.main(ActivityThread.java:5041) 在 java.lang.reflect.Method。在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 在 com.android.internal 的 java.lang.reflect.Method.invoke(Method.java:511) 的 invokeNative(Native Method)。 os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) 原因:android.database.sqlite.SQLiteException: no such column: UserName (code 1): , while compile: SELECT * 来自患者 WHERE 用户名=?ORDER BY AccessedDate at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493 ) 在 android.database 的 android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)。