Search code examples
javascriptsqlitewindows-runtimewinjswin-universal-app

Windows 10 Universal App SQLite


I'm currently trying to port a working Windows 8 JavaScript app to a Windows 10 UAP app. In my Windows 8 app, I heavily used this SQLite wrapper and library: https://github.com/doo/SQLite3-WinRT. However, after adding SQLite3-WinRT to my Windows 10 UAP app as per the setup instructions in the readme of the repo, I get a "WinJS is not defined" error coming from the SQLite3.js source file that I added to my /js directory in the app (the way it works fine in the windows 8 app). Am I doing something wrong here, or wild this SQLite3-WinRT not work with Win 10 UAP and is there some better way of using SQLite in a JavaScript Windows 10 UAP app? Thanks a lot!


Solution

  • I tried using https://github.com/doo/SQLite3-WinRT on Windows 10 and found VS2015 Community Edition couldn't even load the project. Every time I tried to load it, VS would hang with "unloading project" showing in the status bar. Killing it via task manager was the only way out.

    I found this sample app which implements SQLite in a Universal App. This compiles and runs fine for me on Windows 10, although I did have to update the references to SQLite 3.8.4.3 with the version I had, SQLite 3.8.11.1

    1. Download and unzip Universal JavaScript SQLite Sample
    2. Open in Visual Studio
    3. Click on the "Shared App" project group
    4. Expand "SQLite.Windows" > "References"
    5. Remove the reference to "SQLite.WinRT81, Version=3.8.4.3
    6. Right-click > "Add Reference"
    7. From Windows 8.1 > Extensions, select "SQLite for Windows Runtime (Windows 8.1)
    8. Expand "SQLite.WindowsPhone" > "References"
    9. Remove the reference to "SQLite.WP81, Version=3.8.5
    10. Right-click > "Add Reference"
    11. From Windows 8.1 > Extensions, select "SQLite for Windows Runtime (Windows 8.1)
    12. Compile