Android SQLite Exception no such column while inserting -
i'm having problem inserting values table. did 2 tables same principle third 1 causing troubles :/
episode class
public episodes (int eid,int seasonid,string episode,string date,string comment, float rating ) { this.episodeid = eid; this.seasonid = seasonid; this.episode = episode; this.date = date; this.comment = comment; this.rating = rating; } episodes e1 = new episodes(01, 01, "e1", "2012-01-12", "randomcomment01", 5); dbmanager.addepisode(e1);
my dbdesigner class
public class dbdesigner extends sqliteopenhelper { private static final string database_name = "seriesimdb.db"; public static final string table_series = "table_series"; public static final string column_id = "id"; public static final string column_name = "name"; public static final string column_genre = "genre"; public static final string column_rating = "rating"; public static final string column_description = "description"; public static final string table_seasons = "table_seasons"; public static final string column_ssid = "ssid"; public static final string column_seriesid = "id"; public static final string column_sname = "sname"; public static final string table_episodes = "table_episodes"; public static final string column_eid = "eid"; public static final string column_seasonid = "seasonid"; public static final string column_episode = "episode"; public static final string column_date = "date"; public static final string column_episoderating = "rating"; public static final string column_comment = "comment"; private static final string database_create_table_series = "create table " + table_series + "( " + column_id + " integer primary key not null, " + column_name + " text not null," + column_genre + " text not null," + column_rating + " integer not null," + column_description + " text not null);"; private static final string database_create_table_seasons = "create table " + table_seasons + "( " + column_ssid + " integer primary key not null, " + column_seriesid + " integer not null," + column_sname + " text not null," +" foreign key("+column_seriesid+") references table_series("+column_id+") on delete cascade);"; private static final string database_create_table_episodes = "create table " + table_episodes + "( " + column_eid + " integer primary key not null," + column_seasonid + " integer not null," + column_episode + " text," + column_date + " text," + column_comment + " text," + column_episoderating + " integer," +" foreign key("+column_seasonid+") references table_seasons("+column_ssid+") on delete cascade);"; private static final int database_version = 1; public dbdesigner(context context) { super(context, database_name, null, database_version); } @override public void oncreate(sqlitedatabase database) { database.execsql(database_create_table_episodes); database.execsql(database_create_table_series); database.execsql(database_create_table_seasons); }
my dbmanager class tried values , rawquery none of worked.
public void addepisode(episodes newepisode) { contentvalues values = new contentvalues(); log.d("addbook", newepisode.tostring()); values.put(dbdesigner.column_eid, newepisode.episodeid ); values.put(dbdesigner.column_seasonid, newepisode.seasonid); values.put(dbdesigner.column_episode, newepisode.episode); values.put(dbdesigner.column_date, newepisode.date); values.put(dbdesigner.column_comment, newepisode.comment); values.put(dbdesigner.column_episoderating, newepisode.rating); database.insert(dbdesigner.table_episodes, null, values); /*database.rawquery("insert "+dbdesigner.table_episodes+"(" +dbdesigner.column_eid+"," +dbdesigner.column_seasonid+"," +dbdesigner.column_episode+"," +dbdesigner.column_date+"," +dbdesigner.column_comment+"," +dbdesigner.column_episoderating+")" + " values(" +newepisode.episodeid+"," +newepisode.seasonid+"," +newepisode.episode+"," +newepisode.date+"," +newepisode.comment+"," +newepisode.rating+")", null);*/}
i hope data. can 1 see doing wrong ? thank clever people :)
in episode constructor
datatype rating defined float.
public episodes (int eid,int seasonid,string episode,string date,string comment, float rating )
but when creating database episode have defined rating integer type.
private static final string database_create_table_episodes = "create table " + table_episodes + "( " + column_eid + " integer primary key not null," + column_seasonid + " integer not null," + column_episode + " text," + column_date + " text," + column_comment + " text," + column_episoderating + " integer," +" foreign key("+column_seasonid+") references table_seasons("+column_ssid+") on delete cascade);";
may causing problems.
Comments
Post a Comment