Object {message: “sqlite3_prepare_v2 failure: no such table: Tabella_RdA”, code: 0}
you have to create your sql tables before you can read/write data.
before all work fine…now i need to create the db with query inside code and i can’t use prepopulated db like before…If i do query and activate it by button it’s work…
my code:
OPEN DB
db = $cordovaSQLite.openDB({name: “dema.db”, createFromLocation: 1});
console.log("db aperto " + db.name);
function ng-init in page to load db
$scope.selectAllPush = function() {
var query = “SELECT id, rda_numero, oggetto, fornitore, importo, richiedente,data_inserimento, codice_rilascio, materiale, quantita, posizione, centro_di_costo,archiviata, approvata, rifiutata, email,password FROM Tabella_RdA WHERE archiviata = 0”;
$rootScope.allSessions = [];
$cordovaSQLite.execute(db, query, []).then(function(res) {
if(res.rows.length > 0) {
for(var i = 0; i < res.rows.length; i++) {
$rootScope.allSessions.push({
id: res.rows.item(i).id,
rda_numero: res.rows.item(i).rda_numero,
oggetto: res.rows.item(i).oggetto,
fornitore: res.rows.item(i).fornitore,
importo: res.rows.item(i).importo,
richiedente: res.rows.item(i).richiedente,
data_inserimento: res.rows.item(i).data_inserimento,
codice_rilascio: res.rows.item(i).codice_rilascio,
materiale: res.rows.item(i).materiale,
quantita: res.rows.item(i).quantita,
posizione: res.rows.item(i).posizione,
centro_di_costo: res.rows.item(i).centro_di_costo,
archiviata: res.rows.item(i).archiviata,
approvata: res.rows.item(i).approvata,
rifiutata: res.rows.item(i).rifiutata,
email: res.rows.item(i).email,
password: res.rows.item(i).password,
});
$rootScope.allSessionsJSON = JSON.stringify($rootScope.allSessions);
// alert("json " + JSON.stringify($rootScope.allSessions));
console.log("json " + JSON.stringify($rootScope.allSessions));
//console.log("SELECTED -> " + res.rows.item(i).rda_numero + " " + res.rows.item(i).oggetto + " " + res.rows.item(i).richiedente + " " + res.rows.item(i).importo);
}
} else {
console.log("No results found push");
}
}, function (err) {
console.error(err);
});
}
console log
OPEN database: dema.db
DB opened: dema.db
so the app open the db but after in the function call
Object {message: “sqlite3_prepare_v2 failure: no such table: Tabella_RdA”, code: 0}
alse using this under the openDB
var query = “INSERT INTO Tabella_RdA (id, rda_numero, oggetto, fornitore, importo, richiedente,data_inserimento, codice_rilascio, materiale, quantita, posizione, centro_di_costo, archiviata, approvata, rifiutata, email,password) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)”;
$cordovaSQLite.execute(db, query, [null,20022, ‘INSERT APPROVATA’,‘fornitore a’,10,‘richiedente a’,‘15/01/2015’,‘C 18’, ‘F 9’,‘3 pz’,‘p 007’,‘cc 007’,0,0,0,‘qwerty5’,‘qwerty5’]);
the app show this data…but doesn’t load from db!!! but before update yes
and the crazy thing is that i removed the prepop DB from assetts and log say
OPEN database: dema.db SQLitePlugin.js:174
db aperto undefined app.js:58
Object {} app.js:59
new transaction is waiting for open operation SQLitePlugin.js:105
new transaction is waiting for open operation SQLitePlugin.js:105
INSERT INTO Tabella_RdA (id, rda_numero, oggetto, fornitore, importo, richiedente,data_inserimento, codice_rilascio, materiale, quantita, posizione, centro_di_costo, archiviata, approvata, rifiutata, email,password) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) app.js:66
Uncaught TypeError: Cannot read property ‘Keyboard’ of undefined app.js:103
DB opened: dema.db
OPEN DB??? what DB???
the table exist…and before the update working