database - Android: No such column -


here´s log-file:

05-04 09:29:10.968: e/sqlitelog(26491): (1) no such column: datum 05-04 09:29:10.968: d/androidruntime(26491): shutting down vm 05-04 09:29:10.968: w/dalvikvm(26491): threadid=1: thread exiting uncaught exception (group=0x40edc930) 05-04 09:29:10.976: e/androidruntime(26491): fatal exception: main 05-04 09:29:10.976: e/androidruntime(26491): java.lang.runtimeexception: unable start activity componentinfo{com.example.unserekinder/com.example.unserekinder.mainactivity}: android.database.sqlite.sqliteexception: no such column: datum (code 1): , while compiling: select name, datum, geschlecht kind 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activitythread.access$600(activitythread.java:141) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.os.handler.dispatchmessage(handler.java:99) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.os.looper.loop(looper.java:137) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activitythread.main(activitythread.java:5041) 05-04 09:29:10.976: e/androidruntime(26491):    @ java.lang.reflect.method.invokenative(native method) 05-04 09:29:10.976: e/androidruntime(26491):    @ java.lang.reflect.method.invoke(method.java:511) 05-04 09:29:10.976: e/androidruntime(26491):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 05-04 09:29:10.976: e/androidruntime(26491):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 05-04 09:29:10.976: e/androidruntime(26491):    @ dalvik.system.nativestart.main(native method) 05-04 09:29:10.976: e/androidruntime(26491): caused by: android.database.sqlite.sqliteexception: no such column: datum (code 1): , while compiling: select name, datum, geschlecht kind 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqliteconnection.nativepreparestatement(native method) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqliteconnection.acquirepreparedstatement(sqliteconnection.java:882) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqliteconnection.prepare(sqliteconnection.java:493) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitesession.prepare(sqlitesession.java:588) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqliteprogram.<init>(sqliteprogram.java:58) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitequery.<init>(sqlitequery.java:37) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitedirectcursordriver.query(sqlitedirectcursordriver.java:44) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitedatabase.rawquerywithfactory(sqlitedatabase.java:1314) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitedatabase.querywithfactory(sqlitedatabase.java:1161) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitedatabase.query(sqlitedatabase.java:1032) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.database.sqlite.sqlitedatabase.query(sqlitedatabase.java:1200) 05-04 09:29:10.976: e/androidruntime(26491):    @ com.example.unserekinder.dbhelper.select(dbhelper.java:80) 05-04 09:29:10.976: e/androidruntime(26491):    @ com.example.unserekinder.mainactivity.listview_fuellen(mainactivity.java:52) 05-04 09:29:10.976: e/androidruntime(26491):    @ com.example.unserekinder.mainactivity.oncreate(mainactivity.java:27) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activity.performcreate(activity.java:5104) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 05-04 09:29:10.976: e/androidruntime(26491):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 05-04 09:29:10.976: e/androidruntime(26491):    ... 11 more 

i read few other questions problem nothing helped me. seems me 1 column isn´t created.

private static final string tag = dbhelper.class.getsimplename();     private static final string database_name = "unserekinder.db";     private static final int database_version = 2;      public static final string id = "_id";     public static final string table_name_kind="kind";     public static final string name = "name";     public static final string datum = "datum";     public static final string geschlecht = "geschlecht";      private static final string table_kind_create = "create table " + table_name_kind + " (" + id + " integer primary key autoincrement, "      + name + " text, " + datum + " text, " + geschlecht + " text);";        public static final string table_kind_drop = "drop table if exists kind";     public static final string table_kind_delete = "delete table if exists kind";             public dbhelper(context context){         super(context, database_name, null, database_version);     }      @override     public void oncreate(sqlitedatabase db) {         db.execsql(table_kind_create);      } 

you see, statement must executed because in oncreate.

here select statement:

public void insert( string name, string datum, string geschlecht){         long rowid = -1;         try{              sqlitedatabase db = getwritabledatabase();             db.begintransaction();             contentvalues cv = new contentvalues();              cv.put(name, name);             cv.put(datum, datum);             cv.put(geschlecht, geschlecht);              rowid = db.insert(table_name_kind, null, cv);             db.endtransaction();         }         catch (sqliteexception e){             log.e(tag, "insert()", e);         }         finally{             log.d(tag, "insert(): rowid=" + rowid);         }     }      public void create(){         sqlitedatabase db = getwritabledatabase();         db.execsql(table_kind_create);     }      public cursor select(){         sqlitedatabase db = getreadabledatabase();         db.begintransaction();         cursor cursor = db.query(table_name_kind, new string[] {"name", "datum", "geschlecht"},                  "" + "", null, null, null, null);         db.endtransaction();         return cursor;     } 

edit:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     log.w(tag, "upgrade der datenbank von version " + oldversion + "zu " +newversion+ "; alle daten werden gelöscht");     db.execsql(table_kind_drop);     oncreate(db); } 

cursor cursor = db.query(table_name_kind, new string[] {"name", "datum", "geschlecht"}, "" + "", null, null, null, null); query wrong. mean following code? "" + "" can change ""+"" null.try it.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -