2015-11-14 45 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,这款应用运行良好。非常感谢你 –