-1

我已经编写了一个查询来将值插入到 Android 中的数据库中:

db.execSQL("CREATE TABLE " + TABLE_NAME + "( " + KEY_SITUATION_NAME
         + " TEXT NOT NULL, " + KEY_CATEGORY_NAME + " TEXT NOT NULL,"
         + KEY_LATTIUDE +" NOT NULL," + KEY_LONGITUDE + " NOT NULL," + " );");

但是,当我执行它时,会引发错误。谁能指出其中的错误?

4

3 回答 3

1
db.execSQL("CREATE TABLE " + TABLE_NAME + "( " + KEY_SITUATION_NAME
     + " TEXT NOT NULL, " + KEY_CATEGORY_NAME + " TEXT NOT NULL,"
     + KEY_LATTIUDE +" INTEGER NOT NULL," + KEY_LONGITUDE + " INTEGER NOT NULL" + " );");

为 KEY_LATITUDE 和 KEY_LONGITUDE 提供数据类型。

而且你最后保留了一个(,),这是不需要的......

于 2012-04-05T04:28:22.730 回答
0
 db.execSQL("CREATE TABLE " + TABLE_NAME + "( " + KEY_SITUATION_NAME
             + " TEXT NOT NULL, " + KEY_CATEGORY_NAME + " TEXT NOT NULL,"
             + KEY_LATTIUDE +" NOT NULL," + KEY_LONGITUDE + " NOT NULL);");
于 2012-04-05T04:17:40.970 回答
0

正确的代码是:

db.execSQL("CREATE TABLE " + TABLE_NAME + "( " + KEY_SITUATION_NAME
        + " TEXT NOT NULL, " + KEY_CATEGORY_NAME + " TEXT NOT NULL," + KEY_LATTIUDE +" NOT NULL," + KEY_LONGITUDE + " NOT NULL," + " )");
于 2012-04-05T04:22:31.483 回答