2015-06-29 62 views
-1

IM使用SQLite數據庫 做一個應用程序,並且在此沒有這樣的列例外的SQLite

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); 
} 

一個異常即時通訊,這是個日誌:

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

+0

但表的創建是在SqliteHelper類的onCreate數據庫或onUpgrade數據庫? – Santiago

回答

1

您能否請卸載申請一次從設備再次運行? 如果您已經創建的數據庫,你已經添加比數據庫的新列將不能反映馬上就當前的表結構。 所以卸載應用程序將創建與更新數據結構數據庫的新實例後。

+0

感謝我需要這個東西,完全忘了 –

+0

@Radouane Sefraoui,很高興爲您服務。 –