vendredi 6 février 2015

Phonegap Local Storage Database Error 5

Im trying to store messages for a messaging app locally on the devices. Therefore I created a database but I always get back Error 5. My code is essentially similar to the one in many tutorials and the documentation.


Do I have to link a certain js file to my page?


Code:





document.addEventListener("deviceready", onDeviceReady, false);


var db = "";

function onDeviceReady() {
db = window.openDatabase("localmessages", "1.0", "Test_DB", 200000);
db.transaction(populateDB, errorCB, successCB);
}

function populateDB(tx) {
//tx.executeSql("DROP TABLE messages");
tx.executeSql("CREATE TABLE IF NOT EXISTS messages(transmitter_ename varchar(40),receiver_ename varchar(40), message varchar(600)");
}

function errorCB(err) {
alert("Database Error: " + err.code);
}

function successCB() {
alert("Database successfully created");

}


// To add messages to the DB
function savesendmessagetodb(){
db.transaction(
function (tx) {
tx.executeSql("INSERT INTO messages VALUES ( 'trtest','retest','metest'");
}, errorCB);
}



I checked the querys And I couldn't really find any helpful information about that error.


Thanks,


Aucun commentaire:

Enregistrer un commentaire