0

I have created this table

private static class PuntataMetaData {
    static final String TABLE_NAME = "puntata";
    static final String ID = "_id";
    static final String PALINSESTO = "palinsesto";
    static final String NUMEROPALINSESTO = "numeroPalinsesto";
    static final String ESITO = "esito";
    static final String PARTITA = "partita";
    static final String QUOTAZIONE = "quotazione";
}


private static final String PUNTATA_TABLE_CREATE =
        "CREATE TABLE " + PuntataMetaData.TABLE_NAME + " (" +
                PuntataMetaData.ID + " integer primary key autoincrement, " +
                PuntataMetaData.PALINSESTO + " double not null, " +
                PuntataMetaData.NUMEROPALINSESTO + " integer not null, " +
                PuntataMetaData.ESITO + " text not null, " +
                PuntataMetaData.PARTITA + "text not null," +
                PuntataMetaData.QUOTAZIONE + " text not null);";

Now when I search to execute this code

public void inserisciInSchedina(Partite p, String esito, String quot){
    db = getWritableDatabase();
    ContentValues cv = createPuntataContentValues(p.getPalinsesto(), p.getNumeroEvento(), esito, quot, p.getPartita());
    db.insert(PuntataMetaData.TABLE_NAME, null, cv);
    db = getReadableDatabase();
}

private ContentValues createPuntataContentValues(long pal, int numPal, String temp, String temp1, String par) {
    ContentValues cv = new ContentValues();
    cv.put(PuntataMetaData.PALINSESTO, pal);
    cv.put(PuntataMetaData.NUMEROPALINSESTO, numPal);
    cv.put(PuntataMetaData.ESITO, temp);
    cv.put(PuntataMetaData.PARTITA, "Inter-Roma");
    cv.put(PuntataMetaData.QUOTAZIONE, temp1);
    return cv;
}

The Android's debug said to me the following error:

android.database.sqlite.SQLiteException: table puntata has no column named partita: , while compiling: INSERT INTO puntata(numeroPalinsesto,esito,quotazione,partita,palinsesto) VALUES (?,?,?,?,?)

I don't understand where is the error because the field "Partita" exists into the DB Thanks

3
  • 1
    Did you by any chance started out with a table that didn't have the ´partita´ column? If you did and am following the guidelines for using SQLite on Android your create statement is probably not called again and so the table doesn't have the column. Commented Oct 9, 2013 at 17:38
  • Sorry, but i don't understand your answer Darwind, from the start i have created the table Puntata. I opening the DB in read/write mode but when i searching to insert a row i have the error write in the top page Commented Oct 9, 2013 at 17:51
  • Ok, I think maybe you should read up on how Android and SQLite work together. Here's a good tutorial: vogella.com/articles/AndroidSQLite/article.html Anyways - try to remove your app from the device and install it again and see if it helps. If this helps, I'll throw a comprehensive answer to your question and explain exactly why this happens. :-) Commented Oct 9, 2013 at 18:21

3 Answers 3

1
PuntataMetaData.PARTITA + "text not null," +

You are creating a column with the name partitatext and the type not null.

Sign up to request clarification or add additional context in comments.

1 Comment

oh thank you very much CL, i haven't seen this stupid error; and i have lost more 1 hour for this inadvertence
1

Once you change the DB i mean Table like you change the creation of the table then you need to un-install the app in emulator and run it again that will create new version of DB then you can add your data

1 Comment

Also remove the data of the app for making sure.
-1

Go to the Application Manager on your device or your emulator and click on "clear data" button. Then check it again. maybe you create table first without partita column and then you decide to do it. It's better using Database Version in your SQLiteOpenHelper Class to control these problems.

1 Comment

I have proof to clear data on my emulator, Fix project proprierties from Android Tools, clean project from java; but unfortunately the error remains. I don't know what else to do

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.