【问题标题】:SQLite Cordova - Error processing SQL: 5SQLite Cordova - 处理 SQL 时出错:5
【发布时间】:2014-09-30 14:51:06
【问题描述】:
var db = window.openDatabase("Database", "1.0", "userData", 200000);
console.log(db);
db.transaction(populateDB, errorCB, successCB);

function populateDB(tx) {
   tx.executeSql('CREATE TABLE IF NOT EXISTS USER (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, api_key TEXT NOT NULL, username TEXT NOT NULL)');
   tx.executeSql('INSERT INTO USER (api_key, username) VALUES ( "asd", row")');
}

function errorCB(err) {
    console.log("Error processing SQL: "+err.message);
}

function successCB() {
    console.log("success!");
}

第一个 SQL 语句执行,然后第二个返回:

could not prepare statement (1 unrecognized token: "")")  //with error code 5

。任何想法为什么?

我在here关注PhoneGap Docs

【问题讨论】:

  • 您为什么记录code 号码而不是message
  • @CL:已编辑。错误代码似乎比错误本身更有帮助:P
  • 我并没有要求 err 本身。
  • 啊!更改为 err.message 给出了无法准备语句(1 个无法识别的标记:“”)“)

标签: sql sqlite cordova


【解决方案1】:

您伪造了row 字符串的开头引号。

【讨论】:

  • 真的!现在才看到。至少我学到了一些关于 JS 中错误对象的知识。谢谢!
猜你喜欢
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 2018-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-08
  • 1970-01-01
相关资源
最近更新 更多