I'm French so sorry for my bad english, I need some help, I'm trying to copy my database on my webserver into my phonegap application for make a local database, so I've this :
function dlDatabase(){
var db = window.openDatabase("Databases", "1.0", "Cordova Demo", 200000);
db.transaction(createAllTables, errorCB, dlCountry);
}
function createAllTables(tx){
tx.executeSql('CREATE TABLE IF NOT EXISTS Country (id integer primary key, name text, nbQuestion integer)');
tx.executeSql('CREATE TABLE IF NOT EXISTS Question (id integer primary key, text text, CountryId integer)');
tx.executeSql('CREATE TABLE IF NOT EXISTS Answer (id integer primary key, QuestionId integer, text text, isGood boolean)');
}
function insertCountry(tx, id, name, number){
tx.executeSql("INSERT INTO Country(id, name, nbQuestion) VALUES (?,?,?)", [id, name, number]);
}
function dlCountry() {
alert("dlCountry");
$.ajax({
type: "POST",
url: url,
dataType: "json",
data : {
actionname : 'dlCountry'
},
success: function(data) {
arrayCountry = data.arrayCountry;
var db = window.openDatabase("Databases", "1.0", "Cordova Demo", 200000);
db.transaction(function(tx){
for (var i = 0; i < arrayCountry.length; i++) {
alert(arrayCountry[i].id+" "+arrayCountry[i].name+" "+arrayCountry[i].number);
insertCountry(tx, arrayCountry[i].id, arrayCountry[i].name, arrayCountry[i].number);
};
}, errorCB, dlQuestion);
},
error: function(data) {
alert("error !");
}
});
}
I call the dlDatabase function when i login, that's work, but, after insert all the countries ( after the alert ), I've an error code 6 :
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
I'm a beginner in SQLite, what is the error code 6, and how to solve it ? Thank you for your help! :)
Aucun commentaire:
Enregistrer un commentaire