Can't get values from Sqlite DB using query

Posted by Sana Joseph on Stack Overflow See other posts from Stack Overflow or by Sana Joseph
Published on 2012-07-07T15:11:50Z Indexed on 2012/07/07 15:15 UTC
Read the original article Hit count: 228

Filed under:
|
|
|

I used sqlite to populate a DB with some Tables in it. I made a function at another javascript page that executes the database & selects some values from the table.

Javascript:

function GetSubjectsFromDB()
    {
        tx.executeSql('SELECT * FROM Subjects', [], queryNSuccess, errorCB);
    }

    function queryNSuccess(tx, results) {
        alert("Query Success");
        console.log("Returned rows = " + results.rows.length);
        if (!results.rowsAffected) {
            console.log('No rows affected!');
            return false;
        }
        console.log("Last inserted row ID = " + results.insertId);
    }

    function errorCB(err) {
        alert("Error processing SQL: "+err.code);
    }

Is there some problem with this line ?

tx.executeSql('SELECT * FROM Subjects', [], queryNSuccess, errorCB);

The queryNSuccess isn't called, neither is the errorCB so I don't know what's wrong.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html