我已经为选择查询尝试了所有可能的格式:
var queryCust = "SELECT * FROM customers WHERE CustBarcode = '" + CustomerBarcode + "';";
或
var queryCust = "SELECT * FROM customers WHERE CustBarcode like '" + CustomerBarcode + "';";
或
var queryCust = "SELECT * FROM customers WHERE cast(CustBarcode as text) = '" + CustomerBarcode "';";
或带有和不带有'',但没有任何效果,查询未返回任何值!
我什至尝试过
db.executeSql('SELECT * FROM customers WHERE CustBarcode = ?', [ CustBarcode ], function(rs) {...
但是没有用,即使试图用javascript CustBarcode转换为字符串或整数。
下面是函数:
alert(queryCust);
db.executeSql(queryCust, [], function(rs) {
alert(rs.rows.item(0).CustBarcode);
var DescCust = "";
if (rs.rows.item(0).Status == 'NEW'){
DescCust = rs.rows.item(0).Desc + ' ' + rs.rows.item(0).Address;
} else {
DescCust = rs.rows.item(0).CustCode + ' ' + rs.rows.item(0).Desc + ' ' + rs.rows.item(0).Address;
}
document.getElementById("custDesc").innerHTML = DescCust;
}, function(error) {
alert('SELECT SQL statement ERROR while building DescCust: ' + error.message);
});