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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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.