When I tried accessing the database via following code:
var db = sqlitePlugin.openDatabase('SampleDataBase.sqlite3', '1.0', 'Sample', 2 * 1024 * 1024);
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS table1 (key integer, name text)');
});
I got error
"Error: System.ArgumentException: Must be specified"
I later found that it was due to fact that even before the database is opened, the next statement is trying to execute the sql. So, I modified the code, including the sql execution statement in success callback of the opendatabase function:
var db = sqlitePlugin.openDatabase('SampleDataBase.sqlite3', '1.0', 'Sample', 2 * 1024 * 1024, function(){
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS table1 (key integer, name text)');
});
});
But now I am getting following error 80% of the time:
"Error in error callback:TypeError: Unable to get property 'transaction' of undefined or null reference ".
The error clearly implies that db is null. But I cannot find the cause of this error. Is anything wrong in the way I included the sql execution in success callback.
When I tried accessing the database via following code: var db = sqlitePlugin.openDatabase('SampleDataBase.sqlite3', '1.0', 'Sample', 2 * 1024 * 1024); db.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS table1 (key integer, name text)'); }); I got error "Error: System.ArgumentException: Must be specified" I later found that it was due to fact that even before the database is opened, the next statement is trying to execute the sql. So, I modified the code, including the sql execution statement in success callback of the opendatabase function:
var db = sqlitePlugin.openDatabase('SampleDataBase.sqlite3', '1.0', 'Sample', 2 * 1024 * 1024, function(){ db.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS table1 (key integer, name text)'); }); });
But now I am getting following error 80% of the time: "Error in error callback:TypeError: Unable to get property 'transaction' of undefined or null reference ". The error clearly implies that db is null. But I cannot find the cause of this error. Is anything wrong in the way I included the sql execution in success callback.