cordova - Phonegap Sqlite Error processing SQL : 6 -


i'm french sorry bad english, need help, i'm trying copy database on webserver phonegap application make local database, i've :

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 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){                     (var = 0; < 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 dldatabase function when login, that's work, but, after insert countries ( after alert ), i've error code 6 :

function errorcb(err) {     alert("error processing sql: "+err.code); } 

i'm beginner in sqlite, error code 6, , how solve ? thank help! :)

first off all, change alert("error processing sql: "+err.code); alert("error processing sql: "+err.message);.

like described inside cordova/phonegap documentation...

the sqlerror object thrown when error occurs when manipulating database.

this object has 2 properties:

  • code (one of described constants)
  • message: description of error.

detailed answer thing can found here -> how show useful error messages database error callback in phonegap?

like can see in link, error-code 6 means

constraint_err = 6

information constraint error can found here -> http://www.w3schools.com/sql/sql_constraints.asp i'm going inspect code now. far i'm having answer specific problem, i'm going edit. far, information.


Comments