没有这样的列例外源码 [英] no such column exception sqlite

查看:131
本文介绍了没有这样的列例外源码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

做即时通讯使用的SQLite数据库的应用程序 而具有这种异常IM

im doing an application using an sqlite database and im having an exception in this

  public Prof getProffromcompte(int login){
    Cursor c = bdd.query(TABLE_PROF, new String[] {COL_ID_PROF, COL_NOM_PROF, COL_LOGIN_PROF}, COL_LOGIN_PROF + " LIKE \"" + login +"\"", null, null, null, null);
    return cursorToProf(c);
}

这是个日志:

and this is th log :

Process: com.example.radouane.myapplication, PID: 14289
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.radouane.myapplication/com.example.radouane.myapplication.activ2}: android.database.sqlite.SQLiteException: no such column: nom_prof (code 1): , while compiling: SELECT ID_prof, nom_prof, login_prof FROM table_prof WHERE login_prof LIKE "2"
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
        at android.app.ActivityThread.access$800(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5349)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
 Caused by: android.database.sqlite.SQLiteException: no such column: nom_prof (code 1): , while compiling: SELECT ID_prof, nom_prof, login_prof FROM table_prof WHERE login_prof LIKE "2"
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:897)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:508)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1426)
        at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1273)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1144)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1312)
        at com.example.radouane.myapplication.BDD.getProffromcompte(BDD.java:195)
        at com.example.radouane.myapplication.activ2.chooseModule(activ2.java:76)
        at com.example.radouane.myapplication.activ2.onCreate(activ2.java:49)
        at android.app.Activity.performCreate(Activity.java:6020)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2284)

我核实,创建表时我有同样的相同的列名:nom_prof

i verified that when creating the table i have the same same column name : nom_prof

推荐答案

可以请你的卸载从一次应用设备运行了吗? 如果您已经创建了数据库,并且增加了比数据库中的新列将不能反映就在当前的表结构。 所以在卸载应用程序将创建数据库与更新数据结构新实例。

Can you please Uninstall Application once from Device and Run again ? If you have already created database and you have added new column than Database will not reflect right away on current table structure. So after uninstalling application will create new instance of database with updated Data Structure.

这篇关于没有这样的列例外源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆