Click here to Skip to main content
15,895,815 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello so i've been getting this problem from the LOGCAT

"android.database.sqlite.SQLiteException: table salary_table has no column named ID (code 1 SQLITE_ERROR): , while compiling: INSERT INTO salary_table(ID,SALARY,NAME) VALUES (?,?,?)"

And my code is straight out a code that I know works, so my question what is the issue?

Appreciate any help

@Override
   public void onCreate(SQLiteDatabase db) {
       db.execSQL("CREATE TABLE " + TABLE_NAME
               + "(ID INTEGER PRIMARY KEY AUTOINCREMENT,"
               + COLUMN_NAME + " TEXT,"
               + COLUMN_SALARY + " TEXT)");

   }


What I have tried:

Tried several different Create table options.
Posted
Updated 13-Dec-18 6:27am
Comments
Alek Massey 13-Dec-18 10:04am    
Why use autoincrement when the some SQLlite websites advises against it? SQLite AUTOINCREMENT : Why You Should Avoid Using It[^]

The default value in SQLlite for a primary key is a one higher than the highest value for that column in the table. Unless you include a value for the column when inserting.
Member 14088451 13-Dec-18 10:51am    
So basically what ur saying is that I can remove the autoincrement and the outcome will be the same? Tried it and worked without Increment, will have that in mind, thank you.

Had to uninstall and reinstall on the Emulator.
 
Share this answer
 
Why use autoincrement when the some SQLlite websites advises against it? SQLite AUTOINCREMENT : Why You Should Avoid Using It[^]

The default value in SQLlite for a primary key is a one higher than the highest value for that column in the table. Unless you include a value for the column when inserting.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900