Jump to content

sqlite statement not working

Recommended Posts

I have only 1 record ( this is - username,password saved in my table)


I need to select the username and count the no. of rows but both of the things not working, copying my code below



SELECT STATEMENT: returning me [object][object]

var selectStatement = "select username FROM loggedinuser";
var result;

function getusername() 


    db.transaction(function (tx) { 

     function querySuccess(tx, results) {

  for(var i=0; i<results.rows.length; i++) {
            var row = results.rows.item;
            result = { id: row['username']};


COUNT STATEMENT:  below record is giving me result "1"  at alert(len);

var countStatement = "select COUNT(*) from loggedinuser";

var db = openDatabase("AddressBook", "1.0", "Address Book", 200000);  // Open SQLite Database
var user,password;

function countRecord(tx) {
        db.transaction(function (tx) {
    tx.executeSql('SELECT count(*) FROM loggedinuser', [], querySuccess, errorCB);   

function querySuccess(tx, results) {
    var len = results.rows.length;

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

Please help..

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.