Android DataBase错误:没有此类列错误

时间:2015-11-14 03:02:20

标签: java android mysql

这是logcat。

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");已经发生了。 这有什么不对? 请帮助我将不胜感激。 TT

1 个答案:

答案 0 :(得分:2)

首先卸载应用,然后重新安装应用。或者您可以将数据库版本1更改为2.它可能对您有所帮助。