android - Why am i getting the error, Table *tableTame* has no column named *columnName* -
tried updating database version per other posts on stackoverflow no avail
essentially it's android application adds entry database , displays in in listview. when invoke inserta method following error in logcat believe cause of errors)
04-25 13:47:08.697: e/sqlitelog(1783): (1) table adb has no column named p 04-25 13:47:08.747: e/sqlitedatabase(1783): error inserting progress=aa mp=aa an=aa mc=aa wd=aa 04-25 13:47:08.747: e/sqlitedatabase(1783): android.database.sqlite.sqliteexception: table has no column named p (code 1): , while compiling: insert a(p,mp,an,mc,wd) values (?,?,?,?,?)
the question is, why saying there there no column named p when able make others not p?
public void oncreate(sqlitedatabase database) { string sqlitequery = "create table assignments ( " + "assignmentid integer primary key," + "modulecode text, " + "assignmentname text, " + "whendue text, " + "marksproportion text, " + "progress text " + ")"; database.execsql(sqlitequery); } @override public void onupgrade(sqlitedatabase database, int oldversion, int newversion) { string query = "drop table if exists assignments"; database.execsql(query); oncreate(database); } //key valued pair hash map passes values database public void insertassignment (hashmap<string, string> queryvalues) { sqlitedatabase database = this.getwritabledatabase(); contentvalues values = new contentvalues(); values.put("modulecode", queryvalues.get("modulecode")); values.put("assignmentname", queryvalues.get("assignmentname")); values.put("whendue", queryvalues.get("whendue")); values.put("marksproportion", queryvalues.get("marksproportion")); values.put("progress", queryvalues.get("progress")); database.insert("assignments", null, values); database.close(); }
from initial question:
string sqlitequery = "create table adb( " + : "wd text, " + "mp text " + "p text " + ")";
you need comma after mp text
, after other columns before it.
what have there is:
create table adb( ... wd text, mp text p text ) ^^^^^^ problem here.
however, if have added comma , problem still exists, possibility database not being created expect.
you should place debug statements in onupgrade
, oncreate
calls see if being done. if not, find out why they're not being called.
the other possibility that, in over-eagerness protect column names, have made mistake in transcription or removed vital piece of information.
i'm not entirely why think need protect such precious ip column names progress
, modulecode
(especially since can see them in edit history still), should aware such attempts make harder you, not easier :-)
Comments
Post a Comment