0

我为 SQLite 表中的更新记录编写此函数,它不起作用,我不明白为什么,谢谢

    function UpdateValues() {

    var id=document.getElementById("id").value;
    var mydata=document.getElementById("CommonName").value;
    var mydata2=document.getElementById("location").value;
    var mydata3=document.getElementById("datte").value;
    var mydata4=document.getElementById("Observations").value;



    var db = openDatabase('birdsdata1','1.0', 'Test DB', 2 * 1024 * 1024);
    db.transaction(function (tx) {      
      tx.executeSql('CREATE TABLE IF NOT EXISTS birdstabla1 (RegNum INTEGER 

PRIMARY KEY, CommonName CHAR(17), location CHAR(32), datte         CHAR(10), 

Observations CHAR(90))');

tx.executeSql('UPDATE birdstabla1 SET (location, Observations) VALUES (?, ?) 

WHERE RegNum=?', [mydata, mydata2, id], functerr);

    });
    }
4

1 回答 1

4

您的代码中有很多错误,但导致它失败的原因是您的UPDATE语句使用了错误的语法。阅读文档

tx.executeSql('UPDATE birdstabla1' +
              ' SET location = ?, Observations = ?' +
              ' WHERE RegNum = ?',
              [mydata2, mydata4, id]);
于 2013-09-20T07:28:35.817 回答