【发布时间】:2015-07-13 22:58:29
【问题描述】:
我是法国人,很抱歉我的英语不好,我需要一些帮助,我正在尝试将我的网络服务器上的数据库复制到我的 phonegap 应用程序中以创建一个本地数据库,所以我有这个:
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 !");
}
});
}
我在登录时调用了 dlDatabase 函数,这是可行的,但是在插入所有国家/地区后(在警报之后),我有一个错误代码 6:
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
我是SQLite的初学者,错误代码6是什么,如何解决? 谢谢您的帮助! :)
【问题讨论】: