SQLite CreateTable<> Database that already exists is replaced -
database exists replaced calling method createtable <> in sqlite windows 8, erasing lines , creating new table. how can solve? following code analyze:
using(var db = new sqlite.sqliteconnection(app.dbpath)) { db.createtable<listasentid>(); if (db.executescalar<int>("select count(1) listasentid")==0) { db.runintransaction(() => { db.insert(new listasentid() { nome = "lista", eletros = "teste" }); }); } }
not sure language using, if can execute raw sql can use following syntax:
create table if not exists listasentid (nome text, eletros text);
this ensures table listasentid exists without nuking of previous data.
Comments
Post a Comment