0

我正在使用phoneagap框架进行APP开发。在 phonegap 中插入查询:

tx.executeSql('insert into "'+gAppConfig.configTable+'" (key , value) values(uniqueId,"'+uniqueId+'"),(serverURL,"'+serverURL+'")' , querySuccess, errorQuery);

这不起作用,谁能告诉我可能出了什么问题。谢谢。

4

1 回答 1

1

我想您已经在数据库中创建了一个表,并且您已将其命名为“tablename”,其中包含 2 列“id”和“serverURL”;其中“id”是主键。

尝试这个:

   Iquery = "INSERT INTO 'tableName' VALUES(null, "+serverURL+");";
   tx.executeSql(
      Iquery,
      null,
      function(){ /* to do on success, or you may just set it as "null" */},
      function(){ /* to do on error, or you may just set it as "null" */});

或者你可以试试这个:

 tx.executeSql("INSERT INTO tableName(id, serverURL) VALUES (?,?)",
        [null, serverURL], // these are the variables to insert
        function(){ /* to do on success, or you may just set it as "null" */},
        function(){ /* to do on fail, or you may just set it as "null" */});

您可以参考cordova 的原始文档以获取更多信息。

于 2012-12-13T10:44:09.440 回答