Rohit
Rohit

Reputation: 705

sql Query Not Working in slite + phonegap (count the Number of element in table of given name)

i counting the number of element exit in that table but it is not working? I try like that

alert($('.caseName_h').val());

I am getting alert of this val ; After that code is break

var tt  =tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+"'+ $('.caseName_h').val()+'");

I also call like this var tt =tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+ $(".caseName_h").val()); alert(tt)

Undefined come

Upvotes: 0

Views: 169

Answers (1)

Sunil Dodiya
Sunil Dodiya

Reputation: 2615

Try something like this...

db.transaction(function (tx) {
            var caseName_h = $('.caseName_h').val();
            $yoursql = 'SELECT 1 FROM CaseTable WHERE CaseName = "'+caseName_h+'"';
            tx.executeSql($yoursql, [], function (tx, results) {
                if ( results.rows.length == 0 ) {
                    console.log(results.rows);
                }
            });
});

Upvotes: 1

Related Questions