Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SQLite Database(3300): sqlite returned: error code = 1
    primarykey
    data
    text
    <p>I'm starting to go a little mad ha ha, I have spent two days trying to fix this error below, could someone please help me as I can't work it out :( </p> <p>//DB Adapter class to create the table</p> <pre><code>public class DBAdapter { private static final String vd_offer = ("CREATE TABLE " + TABLE_VD_OFFER + " (" + OFFER_ID + " INTEGER, " // PRIMARY KEY + VENUE_ID + " INTEGER, " + OFFER_COST + " INTEGER, " + OFFER_NAME + " TEXT, " + OFFER_DESC_SHORT + " TEXT, " + OFFER_DESC_LONG + " TEXT, " + OFFER_DATE_START + " TEXT, " + OFFER_DATE_END + " TEXT, " + OFFER_RECUR + " TEXT );" ); private final Context context; private DatabaseHelper DBHelper; private SQLiteDatabase db; public DBAdapter(Context ctx) { this.context = ctx; this.DBHelper = new DatabaseHelper(this.context); } private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(vd_offer); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_VD_OFFER); onCreate(db); } } public DBAdapter open() throws SQLException { this.db = this.DBHelper.getWritableDatabase(); return this; } public void close() { this.DBHelper.close(); } } </code></pre> <p>// Class to pass vaiables to DB</p> <pre><code>public class VDOffer { private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; private final Context mCtx; private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } } public VDOffer(Context ctx) { this.mCtx = ctx; } public VDOffer open() throws SQLException { this.mDbHelper = new DatabaseHelper(this.mCtx); this.mDb = this.mDbHelper.getWritableDatabase(); return this; } public void close() { this.mDbHelper.close(); } public long addOffer (int offer_id, int venue_id, int offer_cost, String offer_name, String offer_desc_short, String offer_desc_long, String offer_date_start, String offer_date_end, String offer_recur){ ContentValues values = new ContentValues(); values.put(OFFER_ID, offer_id); values.put(VENUE_ID, venue_id); values.put(OFFER_COST, offer_cost); values.put(OFFER_NAME, offer_name); values.put(OFFER_DESC_SHORT, offer_desc_short); values.put(OFFER_DESC_LONG, offer_desc_long); values.put(OFFER_DATE_START, offer_date_start); values.put(OFFER_DATE_END, offer_date_end); values.put(OFFER_RECUR, offer_recur); return this.mDb.insert(TABLE_VD_OFFER, null, values); } } </code></pre> <p>// Just some code hacked together to test the input</p> <pre><code>public void update (){ int offer_id = 1; int venue_id = 1; int offer_cost = 1; String offer_name = "test"; String offer_desc_short = "test"; String offer_desc_long = "test"; String offer_date_start = "test"; String offer_date_end = "test"; String offer_recur = "test"; VDOffer entry = new VDOffer(Events.this); boolean didItWork = true; try { entry.open(); entry.addOffer(offer_id, venue_id, offer_cost, offer_name, offer_desc_short, offer_desc_long, offer_date_start, offer_date_end, offer_recur); entry.close(); } catch (Exception e) { didItWork = false; String error = e.toString(); Dialog d = new Dialog(this); d.setTitle("Dang it!"); TextView tv = new TextView(this); tv.setText(error); d.setContentView(tv); d.show(); } finally { if (didItWork) { Dialog d = new Dialog(this); d.setTitle("Heck Yea!"); TextView tv = new TextView(this); tv.setText("Success"); d.setContentView(tv); d.show(); entry.close(); } } </code></pre> <p>}</p> <p>// Logs Cat</p> <pre><code>05-29 23:56:43.021: W/KeyCharacterMap(30728): No keyboard for id 0 05-29 23:56:43.021: W/KeyCharacterMap(30728): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 05-29 23:56:47.960: D/dalvikvm(30728): GC_EXTERNAL_ALLOC freed 1925 objects / 139800 bytes in 362ms 05-29 23:56:49.840: I/Database(30728): sqlite returned: error code = 1, msg = no such table: vd_offer 05-29 23:56:49.850: E/Database(30728): Error inserting offer_desc_long=test offer_desc=test offer_date_end=test offer_id=1 offer_recur=test offer_name=test venue_id=1 offer_date_start=test offer_cost=1 05-29 23:56:49.850: E/Database(30728): android.database.sqlite.SQLiteException: no such table: vd_offer: , while compiling: INSERT INTO vd_offer(offer_desc_long, offer_desc, offer_date_end, offer_id, offer_recur, offer_name, venue_id, offer_date_start, offer_cost) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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