gpt4 book ai didi

android.database.sqlite.SQLiteException : no such column: aa: , 编译时:Select Name from stud Where Address=aa

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:00:54 26 4
gpt4 key购买 nike

我正在尝试从 android sqlite 数据库中检索数据,但它的 givine 异常是没有这样的列:


Sqlite Select Query 是 -:

c=db.rawQuery("Select Name from stud Where Address="+a,null);


异常(exception):-

07-04 18:07:00.888: I/Database(648): sqlite returned: error code = 1, msg = no such column: aa
07-04 18:07:00.910: D/AndroidRuntime(648): Shutting down VM
07-04 18:07:00.910: W/dalvikvm(648): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-04 18:07:00.948: E/AndroidRuntime(648): FATAL EXCEPTION: main
07-04 18:07:00.948: E/AndroidRuntime(648): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.StudentInfoManagement/com.my.StudentInfoManagement.ListData}: android.database.sqlite.SQLiteException: no such column: aa: , while compiling: Select Name from stud Where Address=aa
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.os.Looper.loop(Looper.java:123)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-04 18:07:00.948: E/AndroidRuntime(648): at java.lang.reflect.Method.invokeNative(Native Method)
07-04 18:07:00.948: E/AndroidRuntime(648): at java.lang.reflect.Method.invoke(Method.java:507)
07-04 18:07:00.948: E/AndroidRuntime(648): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-04 18:07:00.948: E/AndroidRuntime(648): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-04 18:07:00.948: E/AndroidRuntime(648): at dalvik.system.NativeStart.main(Native Method)
07-04 18:07:00.948: E/AndroidRuntime(648): Caused by: android.database.sqlite.SQLiteException: no such column: aa: , while compiling: Select Name from stud Where Address=aa
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324)
07-04 18:07:00.948: E/AndroidRuntime(648): at com.my.StudentInfoManagement.DataHelper.show(DataHelper.java:86)
07-04 18:07:00.948: E/AndroidRuntime(648): at com.my.StudentInfoManagement.ListData.onCreate(ListData.java:19)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-04 18:07:00.948: E/AndroidRuntime(648): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-04 18:07:00.948: E/AndroidRuntime(648): ... 11 more
07-04 18:07:03.140: I/Process(648): Sending signal. PID: 648 SIG: 9

最佳答案

这只是因为你的sql查询有误。查询文本时,需要在查询字符串两边加上单引号。

你的行应该是:

c=db.rawQuery("Select Name from stud Where Address='"+a+"'",null);

关于android.database.sqlite.SQLiteException : no such column: aa: , 编译时:Select Name from stud Where Address=aa,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11329746/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com