locked
code for use SQLite in html5/javascript windows store RRS feed

  • Question

  • hello people, 

    how to create a select from sqlite db which is on my desktop, and display data on the page html.

    I use it, but not working 

    var dbPath = Windows.Storage.ApplicationData.current.localFolder.path + '\\people.db';

    SQLite3JS.openAsync(dbPath)
                .then(function (db) {
                    console.log('DB opened');
                    return db.eachAsync('SELECT * FROM perscomp;', function (row) {
                        console.log('Get a ' + row.namecomp);
                    });
                })
               .then(function (db) {
                   console.log('close the db');
                   db.close();
               });

    The sqlite3-winrt is work to my project (add references, and sqlite3.js to my project)

    thanks

    Wednesday, October 2, 2013 3:33 PM

All replies

  • Hello people, 

    I'm using SQLite for my data in my app and I can not build db nor show anything.

    i use this code in guthub SQLite3-WinRT. I add the project, included c++ for runtime, sqlite, and reference for project.

    var dbPath = Windows.Storage.ApplicationData.current.localFolder.path + '\\db.sqlite';
            SQLite3JS.openAsync(dbPath)
            .then(function (db) {
                return db.runAsync('CREATE TABLE Item (name TEXT, price REAL, id INT PRIMARY KEY)')
                .then(function () {
                    return db.runAsync('INSERT INTO Item (name, price, id) VALUES (?, ?, ?)', ['Mango', 4.6, 123]);
                })
                .then(function () {
                    return db.eachAsync('SELECT * FROM Item', function (row) {
                        console.log('Get a ' + row.name + ' for $' + row.price);
                    });
                })
                .then(function () {
                    db.close();
                });
            });

    and it's not working, 

    thanks for help me

    Wednesday, October 2, 2013 11:57 AM
  • Hi, Aurelien

    The SQLite3JS.openAsync(dbPath) code means open the sqlite file contain in dbpath. Make sure the db.sqlite file contain in your describe path. And the C:\Users\TheUserName\AppData\Local\Packages\app name\ is the ApplicationData folder which store the application data, settings and states. You could read the document about that link: http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx

    Best Wishes!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 3, 2013 3:56 AM
  • thanks, 

    i put my file people.db in C:\Users\TheUserName\AppData\Local\Packages\app name\LocalState

    but i think it not read my database.


    Thursday, October 3, 2013 10:04 AM
  • Hi, Aurelien

    Do you get some error message? Or your project  can not only read the database, if so, how do you make sure it can not read your database?

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, October 7, 2013 7:25 AM