1

I cannot get javascript to connect to an existing sqlite database that I created and saved as a file with sqlite manager firefox extention.

This is my code but nothing is happening:

$(function() {
    var db;
    if(!window.openDatabase)
        alert('Sqlite not supported');
    else {
        db = window.openDatabase("testDb", "1.0", "DB", 1000000);        

        $("#resultList").html('');
        db.transaction(function(tx) {              
            tx.executeSql('SELECT * FROM users', [], function(tx, result) {
                var dataset = result.rows;
                alert(result.rows.length - 1);
                for(var i = 0; i < dataset.length; i++) {
                    $("#resultList").append("<li>"+dataset.item(i)+"</li>");
                }
            });
        });
    }    
});

Not even the alert in tx.executeSql is alerting.

How do I do this then?

3
  • is this running as part of a HTML page? or as a .jscript file under a specific JS engine? Commented Dec 17, 2015 at 12:19
  • @Charl... This post may help you.. stackoverflow.com/questions/5244471/… Commented Dec 17, 2015 at 12:57
  • It is running as a .js file Commented Dec 18, 2015 at 7:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.