Many many thanks. You are a life-saver
. Now the errors have gone. However I am not able to do insert and select from the database.
var db = null;
document.addEventListener('deviceready', function() {
db = (<any>window).sqlitePlugin.openDatabase({name:'datanew.db', key: 'test', location: 'default'});
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS usertbl (id INTEGER PRIMARY KEY AUTOINCREMENT, loginid string, password string)');
tx.executeSql('INSERT INTO usertbl(loginid, password) VALUES (?,?)', [[this.rndLogin], [this.rndPass]]);
}, function(error) {
console.log('Transaction ERROR: ' + error.message);
}, function() {
console.log('Populated database OK');
});
});
When I try to login and match the input values with those in DB, the login does not go through but no error is shown either. Please guide in this regard.
var db = null;
db = (<any>window).sqlitePlugin.openDatabase({name:'datanew.db', key: 'test', location: 'default'});
db.transaction(function (tx) {
tx.executeSql('select * from usertbl',[], function (tx, resultSet) {
if ((this.loginid == resultSet.rows.item(0).loginid) && (this.password == resultSet.rows.item(0).password))
this.navCtrl.setRoot('HomePage');
else {
alert("Wrong credential !!");
this.loginForm.reset();
}
console.log('Record login (expected to be 1): ' + resultSet.rows.item(0).loginid);
}, function (tx, error) {
console.log('SELECT error: ' + error.message);
}, function (error) {
console.log('transaction error: ' + error.message);
}, function () {
console.log('transaction ok');
});
});