Click here to Skip to main content
15,032,024 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello Guys Help me

error is:
android.database.sqlite.SQLiteException: no such table: employees (code 1 SQLITE_ERROR): , while compiling: INSERT INTO employees
   (name, department, joiningdate, salary)
   VALUES
   (?, ?, ?, ?);


What I have tried:

My code:
private void createEmployeeTable() {
        mDatabase.execSQL(
                "CREATE TABLE IF NOT EXISTS employees (\n" +
                        "    id int NOT NULL CONSTRAINT employees_pk PRIMARY KEY,\n" +
                        "    name varchar(200) NOT NULL,\n" +
                        "    department varchar(200) NOT NULL,\n" +
                        "    joiningdate datetime NOT NULL,\n" +
                        "    salary double NOT NULL\n" +
                        ");"
        );
    }
Posted
Updated 28-May-21 4:48am
v2

1 solution

Quote:

no such table: employees
You are trying to INSERT into a table which does not exist.

The code fragment you've shown is not the code which is generating the error.

Debug your code to find out why your createEmployeeTable method is not being called before you try to access the table.
   

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