samedi 12 mars 2016

Column Not found :android.database.sqlLite.SQLiteException : noSuchColumn : myDate(Code 1)

I was able to insert data in to SQLite table but while retrieving its throwing error, changed database version and all below is my error

public String[] GetTotalFifteenDayRAnge() {
        ArrayList<String> objArray = new ArrayList<String>();
        Cursor objCursor = objDatabase.query(Constants.TotalByRange, new String[]{"myDate"}, null, null, null, null, null);

        //  Cursor objCursor= objDatabase.rawQuery("SELECT myDate FROM  TotalByRange ",null);
        while (objCursor.moveToNext()) {               
            objArray.add(objCursor.getString(objCursor.getColumnIndex("myDate")));
        }
        return (String[]) objArray.toArray(new String[objArray.size()]);
    }

when I tried that raw query its not throwing error but no data in it.Below is the code which I have used for inserting

public void InsertTotalCaloriesByRange(double id, String myDate) {
        ContentValues objContentValues = new ContentValues();
        objContentValues.put("Id", id);
        objContentValues.put("myDate", myDate);

        objDatabase.insert(Constants.TotalByRange, null, objContentValues);

    }

Exact error is : "android.database.sqlLite.SQLiteException : noSuchColumn : myDate(Code 1) : , while compiling : select myDate FROM TotalByRange"

Aucun commentaire:

Enregistrer un commentaire