SQLITE insert into database issue Windows Phone C# -


i totally new in wp development, interested learn.

i have little problem when try insert data sqlite database. weird thing when input data there no problem , doesn't throw exception.

when try close apps , open again simulator data showing, when open database.sqlite sqlite manager firefox addons, data not there. table still empty.

please me out.

private void btnaddexpense_click(object sender, routedeventargs e)         {             datetime datenow = datetime.now;             string format = "yyyy-mm-dd hh:mm:ss";             string d = datenow.tostring(format);              string formatid = "yyyymmddhhmmss";             string id = datenow.tostring(formatid);              int rec;             string strinsert = " insert expense (date,id_category,nominal,detail,icon) values (@date,@id_category,@nominal,@detail,@icon)";               expense tst = new expense                 {                     date = d,                     id_category = cat,                     nominal = amount.text,                     detail = detail_txt.text,                     icon = iconurl,                 };                 rec = (application.current app).db.insert<expense>(tst, strinsert);                 if (rec == 1)                     messagebox.show("row inserted!");                 else                     messagebox.show("row not inserted.");         } 

and use dbhelper.cs insert data

public int insert<t>(t obj, string statement) t : new()         {             try             {                 open();                 sqlitecommand cmd = db.createcommand(statement);                 int rec = cmd.executenonquery(obj);                  return rec;              }             catch (sqliteexception ex)             {                 system.diagnostics.debug.writeline("insert failed: " + ex.message);                 throw ex;             }         } 

any suggestion helpful.

sqlite data copied isolated storage first, insert record table. so, if want view newest db, must open file .sqlite in isolated storage, not @ project folder.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -