android - sqlite returned: error code = 1, msg = no such column: Bateria -
i error every time when run application that
sqlite returned: error code = 1, msg = no such column: bateria
database code
public adminsqliteopenhelper(context context, string nombre, cursorfactory factory, int version) { super(context, nombre, factory, version); } @override public void oncreate(sqlitedatabase db) { db.execsql("create table gas(_id integer primary key autoincrement, " + "estacion text not null, precio intenger not null, fecomgas text not null)"); db.execsql("create table aceite(_id integer primary key autoincrement, " + "marcef text not null, precio intenger not null, fecamac text not null)"); db.execsql("create table repuestos(_id integer primary key autoincrement, tipo text not null, precio intenger not null, fecomrep text not null)"); } @override public void onupgrade(sqlitedatabase db, int versionante, int versionnue) { db.execsql("drop table if exists gas"); db.execsql("create table gas(_id integer primary key autoincrement, " + "estacion text not null, precio intenger not null, fecomgas text not null)"); db.execsql("drop table if exists aceite"); db.execsql("create table aceite(_id integer primary key autoincrement, " + "marcef text not null, precio intenger not null, fecamac text not null)"); db.execsql("drop table if exists repuestos"); db.execsql("create table repuestos(_id integer primary key autoincrement, tipo text not null, precio intenger not null, fecomrep text not null)"); } } the error occurs everytime call method
public void consulta(view v) { adminsqliteopenhelper admin = new adminsqliteopenhelper(this, "mimoto", null, 1); sqlitedatabase bd = admin.getwritabledatabase(); string tipor = tiporep.gettext().tostring(); //string[] repu = new string[] {tipor}; cursor filas = bd.rawquery("select tipo,precio,fecomrep repuestos tipo=" + tipor + "", null); if (filas.movetolast()) { tv01.settext(filas.getstring(0)); tv02.settext(filas.getstring(1)); tv03.settext(filas.getstring(2)); } else //toast.maketext(this, "no existe una persona con dicho dni" + tv3, // toast.length_short).show(); bd.close(); // fin ultimo tanqueo } bateria string tipor, editext
i believe because have enclosed variable tipor contains value bateria in quotes. query should
select tipo,precio,fecomrep repuestos tipo="' + tipor + "'", null); hope helps
Comments
Post a Comment