java 在android studio中执行crud操作时,sql部分发生错误

smdncfj3  于 2023-05-12  发布在  Java
关注(0)|答案(1)|浏览(88)
2021-06-27 10:21:35.255 11487-11487/com.example.studentinfodb E/SQLiteLog: (1) no such column: rollno in "SELECT * FROM student WHERE rollno='1'"
2021-06-27 10:21:35.257 11487-11487/com.example.studentinfodb E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.studentinfodb, PID: 11487
    android.database.sqlite.SQLiteException: no such column: rollno (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM student WHERE rollno='1'
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1045)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:652)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:61)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1545)
        at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1484)
        at com.example.studentinfodb.MainActivity.onClick(MainActivity.java:76)
        at android.view.View.performClick(View.java:7448)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
        at android.view.View.performClickInternal(View.java:7425)
        at android.view.View.access$3600(View.java:810)
        at android.view.View$PerformClick.run(View.java:28305)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
qvtsj1bj

qvtsj1bj1#

请检查数据库。student表中可能没有名为rollno的列。将色谱柱更改为正确的色谱柱,此问题应得到解决。
如果问题仍然存在,请分享整个代码块的代码,而不是仅仅错误。

相关问题