在准备' CREATE TABLE Project_Details时,在0x1f1700上插入失败1(接近" 0":语法错误)时出现错误

时间:2014-10-15 10:40:10

标签: android sqlite

public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub

    String ProjectDetailTable = "CREATE TABLE " + TABLE_PROJECT_DETAIL  + "("
            + ProjectID  + " INTEGER PRIMARY KEY AUTOINCREMENT," + ProjectName + " VARCHAR," + Budget + " VARCHAR," + Duration + " VARCHAR," + StartDate+ " VARCHAR," + ProjectDescription+ " VARCHAR)";

    String ExpensesTable = " CREATE TABLE " + TABLE_PROJECT_EXPENSES + "("+ExpensesID+"INTEGER PRIMARY KEY AUTOINCREMENT,"+ExpProjectName+"VARCHAR," 
                +Date +"VARCHAR,"+ExpensesTitle+"VARCHAR,"+ExpensesAmount+"VARCHAR,"+ExpDescription+"VARCHAR)";
      db.execSQL(ProjectDetailTable);
      db.execSQL(ExpensesTable);



}

2 个答案:

答案 0 :(得分:1)

Column NameColumn Type

之间添加空格
 String ExpensesTable = " CREATE TABLE " + TABLE_PROJECT_EXPENSES + "("+ExpensesID+" INTEGER PRIMARY KEY AUTOINCREMENT,"+ExpProjectName+" VARCHAR," 
            +Date +" VARCHAR,"+ExpensesTitle+" VARCHAR,"+ExpensesAmount+" VARCHAR,"+ExpDescription+" VARCHAR)";

答案 1 :(得分:0)

在第二个查询中在字段名称和字段类型之间添加空格。

String ExpensesTable = " CREATE TABLE " + TABLE_PROJECT_EXPENSES + " ( "+ExpensesID+" INTEGER PRIMARY KEY AUTOINCREMENT,"+ExpProjectName+" VARCHAR," 
                +Date +" VARCHAR,"+ExpensesTitle+" VARCHAR,"+ExpensesAmount+" VARCHAR,"+ExpDescription+" VARCHAR)";