表列未在sqlite中创建

时间:2014-06-13 19:02:01

标签: android sql sqlite android-sqlite

我正在尝试使用2列,名称ID和姓氏创建一个sqlite表;当我运行我的应用程序时,它说"表TABLE_Names没有名为LastName&#34的列;我做错了什么?

       private static final String CREATE_TABLE_Names =  "CREATE TABLE " + "TABLE_Names" +("
              + "NAME_Id" +" INTEGER PRIMARY KEY AUTOINCREMENT, "
              + "LastName"+ " TEXT, " +") ";




          public DataBaseWrapper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }





@Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL(CREATE_TABLE_Names);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    db.execSQL("DROP TABLE IF EXISTS " + "TABLE_Names");
    this.onCreate(db);

}

1 个答案:

答案 0 :(得分:1)

试试这个:

private static final String CREATE_TABLE_Names =  "CREATE TABLE " + "TABLE_Names" +("
              + "NAME_Id" +" INTEGER PRIMARY KEY AUTOINCREMENT, "
              + "LastName"+ " TEXT " +") ";

我在TEXT后删除了逗号。这是SQL中的语法错误。