Et Andrea
Et Andrea

Reputation: 273

Error in SQLite

I'm creating a SQLite, I added 4 columns into my table, but when adding the fifth column "productadd" cannot not be found. What's the problem here? Sorry, I'm really new to sqlite

Below is my DatabaseHelper class

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

My logcat:

 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)

Upvotes: 0

Views: 72

Answers (2)

Mohammod Hossain
Mohammod Hossain

Reputation: 4114

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

Upvotes: 0

Mohamed_AbdAllah
Mohamed_AbdAllah

Reputation: 5322

There is a missing space here:

+ "productprice" 
   + "TEXT,"

Change to :

+ "productprice " 
                + "TEXT,"

Upvotes: 1

Related Questions