0

我正在创建一个 SQLite,我在表中添加了 4 列,但是在添加第五列时找不到“productadd”。这里有什么问题?抱歉,我真的是 sqlite 新手

下面是我的 DatabaseHelper 类

   db.execSQL("CREATE TABLE if not exists producttable(id INTEGER PRIMARY KEY AUTOINCREMENT,"
                + " productidno"
                + " TEXT ,"
                + " productname"
                + " TEXT,"
                + " productprice" 
                + " TEXT,"
                + " productdest" 
                + " TEXT,"
                + " productadd"
                +" TEXT);");

我的日志猫:

 07-28 15:38:49.460: I/Database(382): sqlite returned: error code = 1, msg = table producttable has no column named productadd
07-28 15:38:49.492: E/Database(382): Error inserting productadd=hope productidno=this productdest=and productprice=me productname=is
07-28 15:38:49.492: E/Database(382): android.database.sqlite.SQLiteException: table producttable has no column named productadd: , while compiling: INSERT INTO producttable(productadd, productidno, productdest, productprice, productname) VALUES(?, ?, ?, ?, ?);
07-28 15:38:55.401: E/AndroidRuntime(382):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
4

2 回答 2

1

这里缺少一个空格:

+ "productprice" 
   + "TEXT,"

改成 :

+ "productprice " 
                + "TEXT,"
于 2013-07-28T10:00:31.510 回答
0
 db.execSQL("CREATE TABLE if not exists producttable(id INTEGER PRIMARY KEY AUTOINCREMENT,"
                + " productidno"
                + " TEXT ,"
                + " productname"
                + " TEXT,"
                + " productprice" 
                + " TEXT,"
                + " productdest"
                +" TEXT)");
于 2013-07-28T10:07:15.447 回答