Skip to content Skip to sidebar Skip to footer

No Such Table: (code 1) While Compiling: Select * From Event

First of all, please do NOT mark this question as duplicate because I have searched through EVERY question that has been asked about this error on stackoverflow, but still nothing

Solution 1:

You need a space here:

KEY_ID + "INTEGER PRIMARY KEY,"

So

KEY_ID + " INTEGER PRIMARY KEY,"

Also, I'm not sure why do you execute this other line as well:

db.execSQL("PRAGMA foreign_keys=ON;");

Solution 2:

Finally after some chat in the chat section on stackoverflow, I found my answer. The table wasn't creating in my local database file in the app. Not the server. So I added db=openOrCreateDatabase("StudentDB", Context.MODE_PRIVATE, null); db.execSQL("CREATE TABLE IF NOT EXISTS student(eid VARCHAR,ename VARCHAR,esdate VARCHAR);"); to the onCreate method and it works fine now :)

Solution 3:

Assuming that you have tried it by increasing database version.

1.Make sure you have already created table called event before adding or retrieving data from that table. 2. check your SqliteOpenHelper class for methods onCreate() & onUpgrade(). it should contain some thing like this

privatestaticfinal String DATABASE_CREATE; // your create table sql command@OverridepublicvoidonCreate(SQLiteDatabase database) {
    database.execSQL(DATABASE_CREATE);
  }

  @OverridepublicvoidonUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(MySQLiteHelper.class.getName(),
        "Upgrading database from version " + oldVersion + " to "
            + newVersion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_COMMENTS);
    onCreate(db);
  }

Solution 4:

It takes me 3 hours to solve this problem! This is my solution:

db.execSQL("create table " + CrimeTable.NAME+"("
                + " _id integer primary key autoincrement, "
                + CrimeTable.Cols.UUID + ", "
                + CrimeTable.Cols.TITLE + ", "
                + CrimeTable.Cols.DATE + ", "
                + CrimeTable.Cols.SOLVED + ")" //you should add the space after every ",",just like ", ",notlike ",".the space is important!

Solution 5:

The main reason to this Table Name/Database Table name is not created properly, best way to solve is Create Table Once Again and Update. It Helps me and Solved also.

Post a Comment for "No Such Table: (code 1) While Compiling: Select * From Event"