0

我有动态输入值的代码,当我第一次使用它添加值时,很好,但是当我想编辑它时,旧值没有插入到 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问题:没有插入旧值进行查询,而是插入了新值。如何修复这个错误?

4

1 回答 1

2

您尝试使用名称fitem而不是fitem_x.

注意:除了您的错误之外,您的代码还有几个错误,包括与安全相关的错误。您不会清理输入,例如,用于 SQL 注入攻击。

于 2012-06-07T06:20:19.857 回答