Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
138 views
in Technique[技术] by (71.8m points)

android - no such column exception sqlite

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)

????????????

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...