我做错了什么? ExecuteSql不会抛出任何错误,但实际上没有新条目插入表中。
// connection
var shortName = 'resultsDB';
var version = '1.0';
var displayName = 'QuizResultsDB';
var maxSize = 655360;
localDB = window.openDatabase(shortName, version, displayName, maxSize);
// tables are created succesfully
createTables: function(){
localDB.transaction(function(tx){
// add not null to email
var query = 'CREATE TABLE IF NOT EXISTS results(User_ID INTEGER PRIMARY KEY, Name VARCHAR(255) NOT NULL, CompanyName VARCHAR(255) NOT NULL, EmailAddr VARCHAR(255) NOT NULL, TimeCount INTEGER NOT NULL, ErrorsCount INTEGER NOT NULL)';
tx.executeSql(query, [], function(tx, data){
}, function(tx, error){
//alert('Database table creation error' + error.message + '(' + error.code + ')');
});
});
}, // -createTables
//尝试插入行
localDB.transaction(
function(tx){
var query = 'INSERT INTO results(Name, CompanyName, EmailAddr, TimeCount, ErrorsCount) VALUES(?, ?, ?, ?, ?)';
tx.executeSql(query, [$.cookie('name'), $.cookie('companyName'), $.cookie('email'), parseInt($.cookie('timeNeeded')), parseInt($.cookie('errorsCount'))], function(tx, data){
// no error thrown
}, function(tx, error){
alert("Error saving results to local database " + error.message);
});
答案 0 :(得分:0)
你还记得做过交易承诺吗?