how to drop sqlite table on program start

JamesThompson.9722JamesThompson.9722 GBMember, University

Im creating a shopping application which stores the users selected cart items in an sqlite table, Im wanting to delete that table everytime the application is openned, not restored.

Ive looked at the drop table, but everything I try in their kicks out with an error telling me the table does not exist.

I have this for creating the table

    public CartRepo (string dbPath)
    {
        conn = new SQLiteAsyncConnection (dbPath);
        conn.CreateTableAsync<Product> ().Wait ();
    }

and have tried to do this for deleting the table

    public void DeleteCart ()
    {
        conn.DeleteAsync (conn.Table<Product> ());
    }

but cant seem to get this to work.

Any ideas on how this can be achived ?

Answers

  • HimanshuDwivediHimanshuDwivedi USMember ✭✭
    edited July 2016

    So if you have a SQLiteAsyncConnection object as conn then try this
    conn.DropTableAsync<Product>();

Sign In or Register to comment.