我正在尝试根据id写入数据库。我无法使用输入框指定ID号。如果我在代码中设置数字它工作正常,但是当我尝试从输入中获取id时出现错误。
我的HTML有一个带id='idnumber'
var path= "C:\\Users\\joshr\\fullpathtomyfile\\filename.accdb";
var idnumber = document.getElementById('idnumber').value;
var cn = new ActiveXObject("ADODB.Connection");
var rs = new ActiveXObject("ADODB.Recordset");
var strConn = "Provider=microsoft.ace.oledb.12.0;Data Source=" + path;
cn.Open(strConn);
rs.Open("SELECT MAX(Resolved) FROM reporting", cn);
rs.MoveFirst;
var maxID = rs.Fields.Item(0);
maxID = maxID + 1;
rs.Close();
var sql = "UPDATE reporting SET Resolved='YES' WHERE ID='+idnumber+'";
我也尝试过:
var sql = "UPDATE reporting SET Resolved='YES' WHERE ID='idnumber'";
var sql = "UPDATE reporting SET Resolved='YES' WHERE ID=idnumber";
这个有效,但我需要用户输入数字。
var sql = "UPDATE reporting SET Resolved='YES' WHERE ID=3";
rs.Open(sql, cn);
cn.Close();
我也试过
var sql = "UPDATE reporting SET Resolved='YES' WHERE . ((reporting.ID)='"+idnumber+"')";
结果是“标准表达式中的数据类型不匹配。”
编辑:我仍然需要帮助