Search code examples
c#sqlitewindows-store-apps

Gives Exception (throws) when tries to insert data to SQLite


When I tries to insert data to sqlite in window store app it gives unexpected exception in SQLite.cs file. My code looks like:-

SQLiteConnection con = new SQLiteConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "Fav.db"));
favorities addData = new favorities();
addData.Name = Title.Text;
addData.desciption = desciption.Text;
con.Insert(addData);`

and when I click on button on which these operation are being performed run time exception arises which looks like:-enter image description here

in fact this SQLite.cs file is an API which I downloaded from "Manage Nuget Package" please help me out.
Thanks & Regards,


Solution

  • The table doesn't exist in the database.

    Use this after you create the extension:

    con.CreateTable<favorities>();
    

    The creation of the connection would be better in a using statement too.