connection error with Sqlite database

-1

I want to connect my application with sqlite database but it throw the exception.

An exception of type 'System.BadImageFormatException' occurred in Scrap_Book.Windows.exe but was not handled in user code

Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

        var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "scrapbook.sqlite");
        using (var db = new SQLite.SQLiteConnection(dbpath))

Second line throw exception.

I am unable to resolve it. please help me i am new in programming. Thanks in advance.

c#
sqlite
sqlite3
uwp
asked on Stack Overflow Jul 30, 2016 by vikas sharawat • edited Jul 30, 2016 by vikas sharawat

1 Answer

0

I install sqlite-net package.

@Henk was right, you installed a wrong package for UWP app, what you need is SQLite.Net-PCL package. And for connection, you can code for example like this:

using (var db = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), Path.Combine(ApplicationData.Current.LocalFolder.Path, "scrapbook.sqlite")))
{
    //TODO:
}

and don't forget, your project will also need to reference to SQLite for Universal App Platform.

answered on Stack Overflow Aug 1, 2016 by Grace Feng

User contributions licensed under CC BY-SA 3.0