# After ionic update problem wiht sqlite in android

**URL:** <https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898>\
**Category:** ionic-v1\
**Created:** [November 25, 2015, 2:14pm UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898 "2015-11-25T14:14:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabiobalsamo](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fabiobalsamo](https://forum.ionicframework.com/u/fabiobalsamo)\
**Post date:** [November 25, 2015, 2:14pm UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898/1 "2015-11-25T14:14:29Z")

</div>

Object {message: “sqlite3\_prepare\_v2 failure: no such table: Tabella\_RdA”, code: 0}

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [November 25, 2015, 2:28pm UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898/2 "2015-11-25T14:28:10Z")

</div>

you have to create your sql tables before you can read/write data.

---

<div class="post-metadata">

**Author:** ![fabiobalsamo](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fabiobalsamo](https://forum.ionicframework.com/u/fabiobalsamo)\
**Post date:** [November 25, 2015, 2:33pm UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898/3 "2015-11-25T14:33:44Z")

</div>

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](http://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}

---

<div class="post-metadata">

**Author:** ![fabiobalsamo](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fabiobalsamo](https://forum.ionicframework.com/u/fabiobalsamo)\
**Post date:** [November 25, 2015, 2:42pm UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898/4 "2015-11-25T14:42:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fabiobalsamo](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fabiobalsamo](https://forum.ionicframework.com/u/fabiobalsamo)\
**Post date:** [November 25, 2015, 2:48pm UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898/5 "2015-11-25T14:48:43Z")

</div>

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???

---

<div class="post-metadata">

**Author:** ![fabiobalsamo](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fabiobalsamo](https://forum.ionicframework.com/u/fabiobalsamo)\
**Post date:** [November 26, 2015, 9:09am UTC](https://forum.ionicframework.com/t/after-ionic-update-problem-wiht-sqlite-in-android/37898/6 "2015-11-26T09:09:45Z")

</div>

the table exist…and before the update working
