vendredi 5 février 2016

Referencing and reading from a .sqlite database file (C#/UWP)

All I'm trying to do is use a .sqlite database file that I have stored in the Assets folder of the app (/Assets/CommonCore.sqlite). I'm trying to set up the connection and I've tried a few different things:

    SQLite.Net.SQLiteConnection conn;

    public MainPage()
    {
        this.InitializeComponent();

        conn = new SQLite.Net.SQLiteConnection("Data Source=Assets/CommonCore.sqlite");

but this throws an exception "does not contain a constructor that takes 1 arguments".

    string path;
    SQLite.Net.SQLiteConnection conn;

    public MainPage()
    {
        this.InitializeComponent();

        path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "CommonCore.sqlite");

        conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

but that references a folder "\AppData\Local\Packages\8ed84aca-896d-4286-ba91-e52316db2e89_dzc2ymb8n4xk4\LocalState\CommonCore.sqlite" which obviously isn't the file I need.

I'm sure it's something silly I'm missing.

Aucun commentaire:

Enregistrer un commentaire