-2

i'm using these codes but I am getting error as "table book info has no column named pdate" Database class 's method

public void onCreate(SQLiteDatabase db) {       
// TODO Auto-generated method stub      
String CREATE_BOOK_TABLE = "CREATE TABLE bookinfo ( " +
                "id INTEGER PRIMARY KEY AUTOINCREMENT, " + 
                "title TEXT, "+
                "author TEXT,"+
                 "pdate TEXT)";         
     db.execSQL(CREATE_BOOK_TABLE);     
}
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
Tamer
  • 7
  • 8

2 Answers2

1

Here is another thing that you can try and see if it works.

Did you add pdate field after running your app at least once with a Create query having only id, title, author fields? If yes, then you must increment the database version number and run the app again.

Or as per the comment by @laalto, you must uninstall the app and install again. This is a normal thing during development :)

The database is never created again until you increment the database version even if you change the create queries.

Hope this helps.

jagmohan
  • 2,052
  • 2
  • 26
  • 41
0
public class DatabaseHelper extends SQLiteOpenHelper {

    public static final String CREATE_BOOK_TABLE = "book";

    public DatabaseHelper(Context context) {
        super(context, DB_NAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + CREATE_BOOK_TABLE + "(id INTEGER PRIMARY KEY   AUTOINCREMENT, " + 
                " title TEXT,  "+
                " author TEXT, "+
                " pdate TEXT) ");  

    }

    @Override
    public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
       //if you change somethin you modify this
    }
}
CompEng
  • 7,161
  • 16
  • 68
  • 122
  • @EG i dont think so error is generate for the Space. go to this [http://stackoverflow.com/questions/15230499/table-has-no-column-named-error-sqlite?rq=1](http://stackoverflow.com/questions/15230499/table-has-no-column-named-error-sqlite?rq=1) – M D Mar 21 '14 at 07:20
  • Çok teşekkür ederim ,sorunu çözdüm(Thanks for Everyone,i solved problem) – Tamer Mar 22 '14 at 07:22
  • peki puan verilmeyi hakettim mi :) – CompEng Mar 22 '14 at 09:53