sqlite with HTML and Javascript RRS feed

  • Question

  • Hello,

    i want to write a windows 8 app with database connection. But i have no idea how to connect to a database using html and javascript.

    I know that html5 has a sqlite libary you can use with javascript.

    but if i write

    var db = openDatabase(...);
    i get the message that "openDatabase" is undefined or is there another soloution to connect to a local database?

    Friday, November 30, 2012 6:38 PM

All replies

  • I don't think IE has window.openDataBase.

    I think IE has indexedDB:




    • Proposed as answer by Cobra Tap Saturday, December 1, 2012 10:26 PM
    • Edited by Cobra Tap Saturday, December 1, 2012 10:28 PM
    Saturday, December 1, 2012 10:26 PM
  • so there is no way to use a sql database with windows 8 apps?

    because the indexeddb is not like a sql database


    I tried to use the msIndexedDB but sometimes i get the message that "open" is undefined when I write "window.msIndexedDB.open()"

    and I don't know why because this line you can find in every forum and also on the offical msdn website.

    can someone help me?? it is very strange!


    now it's working! after a restart of visual studio he accepts "msIndexedDB" ;)

    • Edited by Stephan- Sunday, December 2, 2012 4:51 PM
    Sunday, December 2, 2012 11:40 AM
  • Hello again :D,

    i have a new problem with indexeddb.

    if i write

    request.onsuccess = function(e) {
        var db = e.target.result;
        var store = db.createObjectStore(...);

    i get the message "InvalidStateError" and i don't know why. And the same code is on the msdn website

    Has someone an idea and can help me?

    Tuesday, December 4, 2012 3:23 PM
  • Hi,

    You can't use sql database directly with javascript.

    But there has two ways you could select. First, create a web service to handle the data read/write, and then using WinJs.xhr to request that. Second, create a component with c#, and then using that in windows store app.

    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 6, 2012 9:14 AM
  • You can use the SQLite3 WinRT Component (which does not support BLOBs at the moment)
    • Edited by phil_ke Thursday, December 6, 2012 1:28 PM
    Thursday, December 6, 2012 1:27 PM
  • Here is a sample that will give you a working idea of how to use SQLite with a javascript Win8 app


    Thursday, December 6, 2012 7:43 PM
  • please note that using c# components in js apps increases the runtime memory consumption of the app more than using c++ rt components.
    Thursday, December 6, 2012 8:15 PM
  • I succesfully used IndexedDB using Kristof's IndexedDB wrapper (http://linq2indexeddb.codeplex.com/). Its compatible with WinJS and jQuery and works like a charm.

    Nuget package: http://nuget.org/packages?q=linq2indexeddb

    Full example of use: http://users.telenet.be/kristofdegrave/

    Kristof's Blog on Linq2IndexedDB: http://www.kristofdegrave.be/search/label/IndexedDB

    Friday, December 7, 2012 5:43 PM
  • Thank you very much!

    i found out the problem.

    you have to put the createObjectStore part into the onupgradeneeded function and not into the onsuccess function. 

    i found the information in a little sentence on the msdn website.

    Saturday, December 8, 2012 1:19 PM