Note that there are some explanatory texts on larger screens.

plurals
  1. POError when inserting to MSQLite
    text
    copied!<p>I have the following code which collects data (same class) from fields in the layout and tries to put it inside a msqlite database :</p> <pre><code>public void submitOrder(Order order_) { SQLiteDatabase db=DBHelper.getWritableDatabase(); ContentValues cv=new ContentValues(); cv.put(DatabaseHelper.colName, order_.name); cv.put(DatabaseHelper.colLink, order_.link); cv.put(DatabaseHelper.colPrice, order_.price); cv.put(DatabaseHelper.colDateYear, order_.year); cv.put(DatabaseHelper.colDateMonth, order_.month); cv.put(DatabaseHelper.colDateDay, order_.day); db.insert(DatabaseHelper.orderTable, null, cv); db.close(); </code></pre> <p>And i have the MSQlite database helper Class i've created :</p> <pre><code>package com.Sagi.MyOrders; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class DatabaseHelper extends SQLiteOpenHelper { static final String dbName="DBname"; static final String orderTable="Orders"; static final String colName="OrderName"; static final String colLink="OrderLink"; static final String colDateYear="DateYear"; static final String colDateMonth="DateMonth"; static final String colDateDay="DateDay"; static final String colPrice="OrderPrice"; static String CREATE_T; public DatabaseHelper(Context context) { super(context, dbName, null,1); } /** Called when the activity is first created. */ @Override public void onCreate(SQLiteDatabase db) { CREATE_T="CREATE TABLE orderTable (" + "colName TEXT," + "colLink TEXT," + "colPrice TEXT," + "colDateYear INTEGER," + "colDateMonth INTEGER," + "colDateDay INTEGER);"; db.execSQL(CREATE_T); Log.e("Table creator","Table Created successfully"); } </code></pre> <p>When i run it and click on the button to store the info in the DB, i get an error message :</p> <pre><code>06-02 06:19:43.454: E/Database(1570): android.database.sqlite.SQLiteException: table Orders has no column named OrderPrice: , while compiling: INSERT INTO Orders(DateDay, DateMonth, OrderLink, OrderName, OrderPrice, DateYear) VALUES(?, ?, ?, ?, ?, ?); </code></pre> <p>And an I level message :</p> <pre><code>06-02 06:19:43.444: I/Database(1570): sqlite returned: error code = 1, msg = table Orders has no column named OrderPrice </code></pre> <p>Hope you can help ... thanks !</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