Closed anilkunchalaece closed 7 years ago
Can you paste the log from Xcode? or do this in error function console -
console.log("error in copy db", error)
INSTALL SUCCESS
LAUNCH SUCCESS
0 178269 log error in copy db, DB Already Exists
1 178271 log Error in Error callbackId: sqlDB368979961 : Error: Database location or iosDatabaseLocation setting is now mandatory in openDatabase call.
JS changed: www/js/app.js
JS changed: www/js/app.js
0 182186 log error in copy db, DB Already Exists
i am using ionic run command.
Hi, Problem is in line
db = $cordovaSQLite.openDB("demo.db");
thanks for quick reply
Like the error says you have to pass databaselocation or iOSDatabaseLocation paramter while opening the db. For. e.g
$cordovaSQLite.openDB({name : 'demo.db.sqlite',location : 'default'});
location depends on where you copied the db.
Hi, i am not getting any tables from the data base, where am i doing wrong ?
` window.plugins.sqlDB.copy("demo.db",0,function() {
console.log("db read")
db = $cordovaSQLite.openDB({name : 'demo.db',location : 'default'});
}, function(error) {
console.log("error in copy db",error.message)
db = $cordovaSQLite.openDB({name: "demo.db",location: 'default'})
})`
and in controller
` $scope.showTables = function(){
console.log("show table")
$cordovaSQLite.execute(db,"SELECT name FROM sqlite_temp_master WHERE type=?",['table']).then(function(res){
console.log("tables"+res.rows.length)
}),function(err){
console.log('error in reading tables'+err)
}
}
})`
in assests folder the db is copying and have the tables
Remove the old db and recopy it. I think there might something wrong with the database or query. Use this to check sqlite database - http://sqlitebrowser.org/
it is showing file. for reading the data i am using this, it's also giving me nothing
$scope.loadDb = function(){
console.log("values reading from db");
$scope.val = [];
$cordovaSQLite.execute(db, "SELECT * FROM example").then(function(res) {
console.log(res.rows.length);
for (var i = 0; i < res.rows.length; i++) {
$scope.val.push(res.rows.item(i).firstname)
//console.log('added' + res.rows.item(i).firstname)
}
}),function(err){
console.log('error'+err.message)
}
// })
}
Have you deleted the old app and installed new app? Also what is the error message in $cordovaSQLite.execute function?
i uninstalled and run the emulator. now it is working. Thankyou so much for your quick replys.. btw what is the problem ?
It might be database location problem which was copied somewhere else. Sqlite Plugin would have created a new blank database.
When i tried the following
It is giving me following error
i think i am specifying the location.. isn't it ? Or am i doing anything wrong ?