我有动态输入值的代码,当我第一次使用它来添加值时,它很好,但是当我想编辑它时,旧的值没有插入sql查询但是插入新值
以下是示例:
这是代码:
============功能=================
sub ShowItemfgEdit(query,selItemName,defValue,num,cdisable)
response.write "<select " & cdisable & " num=""" & num & """ id=""itemCombo"" name=""" & selItemName & """ class=""label"" onchange=""varUsage.ChangeSatuanDt(this)"">"
if NOT query.BOF then
query.moveFirst
WHILE NOT query.EOF
tulis = ""
if trim(defValue) = trim(query("ckdbarang")) then
tulis = "selected"
end if
response.write "<option value=""" & trim(query("ckdbarang")) & """" & tulis & ">" & trim(query("ckdbarang")) & " - " & trim(query("vnamabarang"))
query.moveNext
WEND
end if
response.write "</select>"
end sub
============调用函数================
<td class="rb" align="left"><% call ShowItemfgEdit(qGetItemfgGrp,"fitem",qGetUsageDt("ckdfg"),countLine,readonlyfg) %></td>
==============发布值======================
<input type="hidden" name="fitem" value="">
================获取值===================
for i = 1 to request.form("hdnOrderNum")
if request.form("selOrdItem_" & i) <> "" then
'bla...blaa...blaa...
ckdfg = trim(request.form("fitem_" & i)) '<==here is the problem
objCommand.commandText = "INSERT INTO IcTrPakaiDt " &_
"(id, id_h, ckdunitkey, cnopakai, dtglpakai, ckdbarang, ckdgudang, nqty1, nqty2, csatuan1, csatuan2, nqtypakai, csatuanpakai, vketerangan, cJnsPakai, ckdprodkey, ckdfg, ncountstart, ncountstop, ncounttotal) " &_
" VALUES " &_
" (" & idDt & ",'" & idHd & "','" & selLoc & "','" & nopakai & "','" & cDate(request.form("hdnUsageDate")) & "','" & trim(ckdbarang) & "','" & trim(ckdgudang) & "'," & nqty1 & "," & nqty2 & ",'" & trim(csatuan1) & "','" & trim(csatuan2) & "'," & nqtypakai & ",'" & csatuanpakai & "','" & trim(keteranganItem) & "','" & trim(cjnspakai) & "','" & ckdprodkey & "','" &ckdfg& "'," & cnt1 & "," & cnt2 & "," & totalcnt & ")"
set qInsertPakaiDt = objCommand.Execute
end if
next
问题:ckdfg
的旧值未插入查询,但插入了新值。
如何解决这个错误?
答案 0 :(得分:2)
您尝试发布名称为fitem
而非fitem_x
的字段。
注意:除了你的bug之外,你的代码还有几个bug,包括与安全相关的bug。您不会清理输入,例如,针对SQL注入攻击。