-1

I have the following code:

var db = openDatabase('CBDB', '1.0', 'mySpecialDatabaseThatWontWork',10*1024*1024);
    db.transaction(function (nw){
        nw.executeSql('Drop TABLE user');           
    });

    function db1(){
        var db = openDatabase('CBDB', '1.0', 'mySpecialDatabaseThatWontWork',10*1024*1024);
        db.transaction(function (tx){
            createDB();
            queryDB();
        });
        function createDB(){
            db.transaction(function (tx){
            tx.executeSql('CREATE TABLE IF NOT EXISTS login(empid unique, name varchar(20), pass varchar(20), manager varchar(20))');
            tx.executeSql('INSERT INTO login (empid,name,pass,manager) VALUES ("1234567","Krishnaji","12345","9999999")');
            tx.executeSql('INSERT INTO login (empid,name,pass,manager) VALUES ("1000001","Gourav","12345","1234567")');
            tx.executeSql('INSERT INTO login (empid,name,pass,manager) VALUES ("1000002","Manju","12345","1234567")');
            tx.executeSql('CREATE TABLE IF NOT EXISTS user(empid varchar(10))');
            });
        }
        function queryDB(){
            db.transaction(function (tx){
            var x = $('#nameT').val();
            tx.executeSql('INSERT INTO user (empid) VALUES (?)', [x]);
            var u = $("#nameT").val();
            var p = $("#nameP").val();
            tx.executeSql('SELECT * FROM login WHERE empid="?" and pass="?"',[u,p], function valid(tx,results){
                var len = results.rows.length;
                console.log(len);
                if (len == 1) {
                    window.location.assign("www/landing.html");
                } else{
                    //alert("Invalid Employee ID or Password");
                };
            });
        });
        }
        }

Now the problem is that javascript does not enter the transaction function.

I have tried the solution of a similar question about removing the alerts, but it didn't work for me.

GouravR
  • 184
  • 1
  • 9
  • 1
    You're aware that web-sql is deprecated and shouldn't be used for new code - right? – Benjamin Gruenbaum Apr 22 '15 at 10:52
  • 1
    Yes I'm aware of that. I'm building a phonegap app and phonegap supports only websql across android,iOS and windows phone. If there is an alternative please provide it. – GouravR Apr 22 '15 at 11:16

1 Answers1

0

The problem is that transaction() will execute only one executesql statement.

GouravR
  • 184
  • 1
  • 9