vbscript的新手,不是特别喜欢它,但我的客户使用它,所以我不能做太多的事情!我在使用参数化查询将数据添加到数据库时遇到问题!请救救我们!!
到目前为止,现有代码是
function ecaddupdateDEV (thistable, idvar, vararray)
for each varname in vararray
valstring = valstring & ", session(""" & varname & """)"
thesefields = thesefields & ", " & varname
next
thesefields = idvar & thesefields
valstring = " array( " & ecremovel(valstring, 2) & ")"
vals = eval(valstring)
set temprs = Server.CreateObject("ADODB.RecordSet")
if session(idvar) = 0 then
'response.Write("chid is 0 add new record")
' ADD THIS REC
temprs.open thistable, db,1,3,2
temprs.AddNew vararray, vals
ecaddupdateDEV = temprs(idvar)
temprs.close
set temprs = ecquery("select " & idvar & " from " & thistable & " order by " & idvar & " desc ")
ecaddupdateDEV = temprs(idvar)
else
' UPDATE THIS REC
selectclause = "select " & thesefields & " from " & thistable & " where " & idvar & " = " & session(idvar)
temprs.open selectclause, db ,1,3
temprs.update vararray, vals
ecaddupdateDEV = temprs(idvar)
temprs.close
end if
set temprs = nothing
end function
我想为安全目的进行参数化的temprs变量,显然大声笑!我根本不知道怎么做!我读过的内容我发现令人困惑,请帮助!!非常感谢提前!
答案 0 :(得分:0)
使用命令而不是Recordset。这是一个例子,它可以帮助您,但您可能需要调整它,因为从经验来看,命名参数并不真正起作用,因此您按照它们在SQL语句中出现的顺序分配它们的值。
How To Call a Parameterized Query to an Access Database with ADO