2015-11-14 72 views
1

這是logcat。Android數據庫錯誤:沒有這樣的列錯誤

11-14 11:38:28.915 30243-30243/com.example.multical E/SQLiteLog﹕ (1) **no such column: isu** 
11-14 11:38:28.925 30243-30243/com.example.multical E/AndroidRuntime﹕ **FATAL EXCEPTION: main** 
Process: com.example.multical, PID: 30243 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.multical/com.example.multical.grade}: **android.database.sqlite.SQLiteException: no such column: isu (code 1): , while compiling: SELECT _id, subject, semester, credit, grade, isu FROM mygrades ORDER BY _id DESC** 

Caused by: android.database.sqlite.SQLiteException: no such column: isu (code 1): , while compiling: SELECT _id, subject, semester, credit, grade, isu FROM mygrades ORDER BY _id DESC 
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 

**at com.example.multical.DBAdapter.getAllInfo(DBAdapter.java:88) 
     at com.example.multical.grade.onCreate(grade.java:81)** 

com.example.multical.DBAdapter.getAllInfo(DBAdapter.java:88) source 

Cursor c = db.query(TABLE_NAME, new String[]{ID, SUBJECT, SEMESTER, CREDIT, GRADE, ISU}, null, null, null,null, ID + " DESC"); 

com.example.multical.grade.onCreate(grade.java:81)** 

    mInfo = mDb.getAllInfo(); 

和將對DBAdapter vairables

private static final String DB_NAME = "mygrade.db"; 
private static final int VERSION = 1; 
public static Cursor cursor; 
private static final String ID = "_id"; 
private static final String SUBJECT = "subject"; 
private static final String SEMESTER = "semester"; 
private static final String GRADE = "grade"; 
private static final String ISU = "isu"; 
private static final String CREDIT = "credit"; 
private static final String TABLE_NAME = "mygrades"; 
public static int count; 
private static final String CREATE_TABLE = 
    "CREATE TABLE " + TABLE_NAME + " (" + 
    ID + " integer primary key autoincrement, " + 
      SUBJECT + " text not null, " + 
      SEMESTER + " text not null," + CREDIT +" text not null, " + GRADE +" text not null, " + ISU + " text not null);"; 

也許,我認爲Cursor c = db.query(TABLE_NAME, new String[]{ID, SUBJECT, SEMESTER, CREDIT, GRADE, ISU}, null, null, null,null, ID + " DESC");已happend。 有什麼不對? 請幫助我,將不勝感激。 TT

+0

@Johnmin如果你改變你的表格結構並且數據庫中的舊錶格沒有改變,這是可能的。要改變它,你必須增加數據庫版本,或者你必須清除舊的數據 –

回答

2

先卸載應用程序,然後重新安裝應用程序。或者您可以將數據庫版本1更改爲2.它可能對您有所幫助。

+0

哦!謝謝。由於Chaning數據庫版本2,這款應用運行良好。非常感謝你 –