Cordova SQLite插件错误代码

时间:2016-03-25 06:18:51

标签: angularjs sqlite cordova ionic-framework cordova-plugins

有人可以向我解释我的离子/ cordova应用程序在写入已打开的SQLite DB时返回的错误消息吗?

从中读取它可以正常工作,但写入不起作用......

[Log] {"db":{"openargs":{"name":"mydb.db","dblocation":"docs"},"dbname":"mydb.db"},"txlock":true,"readOnly":false,"executes":[],"finalized":true} (console-via-logger.js, line 174)

这是SQLite在运行写入事务之前输出的内容:

[Log] OPEN database: mydb.db (console-via-logger.js, line 174)
[Log] new transaction is waiting for open operation (console-via-logger.js, line 174)
[Log] DB opened: mydb.db (console-via-logger.js, line 174)

我的写作方式

myDB.transaction(function(transaction) {
             var query = "UPDATE Data SET Values='"+dataJSON+"'";
//           console.log(query);
             transaction.executeSql(query,[],
             //On Success
             function(tx, result) {
//               console.log('UPDATE SUCCESSFULLY');
                 deferred.resolve(true);
             },
             //On Error
             function(error){
//               console.log('Backing up data to DB failed');
                 deferred.reject(error);
             });
    });

1 个答案:

答案 0 :(得分:1)

尝试像这样编码。

function(name,email,phoneno){
var deferred = $q.defer();
posts = undefined;
var query = "UPDATE Data SET Name=?, Email=?, Phone=?";
$cordovaSQLite.execute(dbconn, query, [name,email,phoneno])
.then(function(result) {
posts = result;
deferred.resolve(posts);
}, function (error) {
posts = error;
deferred.reject(posts);
});
posts = deferred.promise;
return $q.when(posts);    
}