我正在尝试从表USERS中删除用户。不幸的是,我一直被发送到onSqlError。我无法弄清楚为什么。当我提醒请求时,它为我提供了getTheId变量的正确名称。不太熟悉sql所以也许我写错了。任何指针赞赏。
// DELETE RECORD
function deleteRecord(getTheId){
deleteUser.onclick = (function () {//deleteUser is an element generated for each user when a button is clicked
var sqlStr2 = 'DELETE FROM USERS WHERE username = '+getTheId+'';
alert("SQL: " + sqlStr2); //This gives me the statement above with the correct name of the user clicked.
if (db){
console.log("db is there");//this logs
db.transaction(function(tx) {
tx.executeSql(sqlStr2);
}, onSqlError, onSqlSuccess); //THEN I GET SENT TO ERROR
}
});
}
答案 0 :(得分:1)
试试这个:
var sqlStr2 = "DELETE FROM USERS WHERE username = '"+getTheId+"'";
答案 1 :(得分:0)
尝试添加';'在你的陈述结束时,虽然没有错误信息,但很难说。