locked
can we combine javascript & sqlite to store data dynamically ??

    Question

  • i know that its weird , but please anyone tell me whether we can combine javacript & sqlite to store data dynamically , if so please explain me how?? 
    Sunday, August 11, 2013 6:42 AM

Answers

  • Hi Kranthi88,

    You can follow the steps to make SQLite3JS works fine for you:

    1, Add the SQLite3 C++ project (SQLite3\SQLite3.vcxproj) to your solution.

    2, Add a reference to it from the JavaScript project in your solution:

    Right-click on the JS project in solution explorer, Click add reference, Select solution, Add the checkmark for SQLite3 project.

    And make sure that you add the C++ project to the solution, not to your JavaScript project. It is added correctly if there is a little triangle left to SQLite3 in the solution explorer.

    ====

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    James He
    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.


    Tuesday, August 13, 2013 11:02 AM
    Moderator

All replies

  • Hi kranthi88,

    Normally we use JavaScript as the front-end application while using C#/C++ component as a controller to communicate with the sqlite. Here is a Github link for you to know how to use JavaScript to communite with a sqlite database, by using the sample code below you will be able to do so.

    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();
      });
    });

    Best Regards,   


    James He
    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.

    Monday, August 12, 2013 6:35 AM
    Moderator
  • hii james i copied your code & pasted it in default.js file in my blank javascript application , it is saying that javascript run time error :   'SQLite3JS' is undefined , i have already installed sqlite3 extension & referenced it to my project , how to solve this please tell me
    Tuesday, August 13, 2013 7:14 AM
  • Hi Kranthi88,

    You can follow the steps to make SQLite3JS works fine for you:

    1, Add the SQLite3 C++ project (SQLite3\SQLite3.vcxproj) to your solution.

    2, Add a reference to it from the JavaScript project in your solution:

    Right-click on the JS project in solution explorer, Click add reference, Select solution, Add the checkmark for SQLite3 project.

    And make sure that you add the C++ project to the solution, not to your JavaScript project. It is added correctly if there is a little triangle left to SQLite3 in the solution explorer.

    ====

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    James He
    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.


    Tuesday, August 13, 2013 11:02 AM
    Moderator
  • thanx jamles
    Tuesday, August 13, 2013 1:29 PM