Note that there are some explanatory texts on larger screens.

plurals
  1. POsqlite returned: error code = 1, msg = no such column: TELEPHONE,
    text
    copied!<p>I get the following message when I try to lauch the application.</p> <pre><code>sqlite returned: error code = 1, msg = no such column: TELEPHONE,** </code></pre> <p>Here is my code: </p> <pre><code>public class RestaurantBDD { public static final int VERSION = 1; public static final String NOM_BDD = "restaurant.db"; public static final String TABLE_RESTAURANTS = "restaurants"; public static final String COL_ID = "ID"; public static final int NUM_COL_ID = 0; public static final String COL_NAME = "NAME"; public static final int NUM_COL_NAME = 1; public static final String COL_ADRESSE = "ADRESSE"; public static final int NUM_COL_ADRESSE = 2; public static final String COL_GENRE = "GENRE"; public static final int NUM_COL_GENRE = 3; public static final String COL_NOTES = "NOTES"; public static final int NUM_COL_NOTES = 4; public static final String COL_TELEPHONE = "TELEPHONE"; public static final int NUM_COL_TELEPHONE = 5; private SQLiteDatabase bdd; private RestaurantHelper restaurants; public RestaurantBDD(Context context){ restaurants = new RestaurantHelper(context, NOM_BDD, null, VERSION); } public void openForWrite(){ bdd = restaurants.getWritableDatabase(); } public void openForRead(){ bdd = restaurants.getReadableDatabase(); } public void close(){ bdd.close(); } public SQLiteDatabase getBdd(){ return bdd; } public long insertRestaurant(Restaurant restaurant){ ContentValues content = new ContentValues(); content.put(COL_NAME, restaurant.getNom()); content.put(COL_ADRESSE, restaurant.getAdresse()); content.put(COL_GENRE, restaurant.getGenre()); content.put(COL_NOTES, restaurant.getNotes()); content.put(COL_TELEPHONE, restaurant.getTelephone()); return bdd.insert(TABLE_RESTAURANTS, null, content); } public int updateRestaurant(int id, Restaurant restaurant){ ContentValues content = new ContentValues(); content.put(COL_NAME, restaurant.getNom()); content.put(COL_ADRESSE, restaurant.getAdresse()); content.put(COL_GENRE, restaurant.getGenre()); content.put(COL_NOTES, restaurant.getNotes()); content.put(COL_TELEPHONE, restaurant.getTelephone()); return bdd.update(TABLE_RESTAURANTS, content, COL_ID + " = " + id, null); } public int removeRestaurant(String nom){ return bdd.delete(TABLE_RESTAURANTS, COL_NAME + " = " + nom, null); } public Restaurant getRestaurant(String nom){ Cursor c = bdd.query(TABLE_RESTAURANTS, new String[] { COL_ID, COL_NAME, COL_ADRESSE,COL_GENRE, COL_NOTES, COL_TELEPHONE}, COL_NAME + " LIKE \"" + nom + "\"", null, null, null, COL_NAME); return cursorToRestaurant(c); } public Restaurant cursorToRestaurant(Cursor c){ if(c.getCount() == 0){ c.close(); return null; } Restaurant restaurant = new Restaurant(); restaurant.setId(c.getInt(NUM_COL_ID)); restaurant.setNom(c.getString(NUM_COL_NAME)); restaurant.setAdresse(c.getString(NUM_COL_ADRESSE)); restaurant.setGenre(c.getString(NUM_COL_GENRE)); restaurant.setNotes(c.getString(NUM_COL_NOTES)); restaurant.setTelephone(c.getString(NUM_COL_TELEPHONE)); c.close(); return restaurant; } public ArrayList&lt;Restaurant&gt; getAllRestaurants(){ Cursor c = bdd.query(TABLE_RESTAURANTS, new String[] { COL_ID, COL_NAME, COL_ADRESSE, COL_GENRE, COL_NOTES, COL_TELEPHONE}, null, null, null, null, COL_NAME); if(c.getCount() == 0){ c.close(); return null; } ArrayList&lt;Restaurant&gt; restaurantList = new ArrayList&lt;Restaurant&gt; (); while(c.moveToNext()){ Restaurant restaurant = new Restaurant(); restaurant.setId(c.getInt(NUM_COL_ID)); restaurant.setNom(c.getString(NUM_COL_NAME)); restaurant.setAdresse(c.getString(NUM_COL_ADRESSE)); restaurant.setGenre(c.getString(NUM_COL_GENRE)); restaurant.setNotes(c.getString(NUM_COL_NOTES)); restaurant.setTelephone(c.getString(NUM_COL_TELEPHONE)); restaurantList.add(restaurant); } c.close(); return restaurantList; } } </code></pre> <p>my other class</p> <pre><code>public class RestaurantHelper extends SQLiteOpenHelper{ public static final String TABLE_RESTAURANTS = "restaurants"; public static final String COL_ID = "ID"; public static final String COL_NAME = "NAME"; public static final String COL_ADRESSE = "ADRESSE"; public static final String COL_GENRE = "GENRE"; public static final String COL_NOTES = "NOTES"; public static final String COL_TELEPHONE = "TELEPHONE"; private static final String CREATE_BDD = "CREATE TABLE " + TABLE_RESTAURANTS + " ( " + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_NAME + " TEXT NOT NULL, " + COL_ADRESSE + " TEXT NOT NULL, " + COL_GENRE + " TEXT NOT NULL, " + COL_NOTES + " TEXT NOT NULL, " + COL_TELEPHONE + " TEXT NOT NULL " + " ); "; public RestaurantHelper(Context context, String name,CursorFactory factory, int version) { super(context, name, factory, version); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_BDD); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE"+ TABLE_RESTAURANTS); onCreate(db); } } </code></pre> <p>My LogCat:</p> <pre><code>: sqlite returned: error code = 1, msg = table restaurants has no column named TELEPHONE, db=/data/data/com.example.restaurant/databases/restaurant.db : Error inserting GENRE=take-out ADRESSE=brossard NAME=mcdo TELEPHONE=450-555-5555 NOTES=fastfood : android.database.sqlite.SQLiteException: table restaurants has no column named TELEPHONE: , while compiling: INSERT INTO restaurants(GENRE,ADRESSE,NAME,TELEPHONE,NOTES) VALUES (?,?,?,?,?) at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) at android.database.sqlite.SQLiteCompiledSql.&lt;init&gt;(SQLiteCompiledSql.java:68) </code></pre> <p>I get the following message when I try to lauch the application. sqlite returned: error code = 1, msg = no such column: TELEPHONE,**</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload