为什么这些asp复选框值没有传递给SQL?

时间:2015-04-27 14:03:17

标签: asp-classic

代码似乎提前工作,我不确定是否进行了任何更改或者是什么,但现在这不能用于保存复选框值。但是,在页面加载时检索旧的已保存值没有问题。任何人都可以看到为什么现在没有插入值的原因?

复选框代码:

<%if confirmationstatusarray(k) = True Then%>
<td colspan="1"><input type="checkbox" id = "confirmation(<%=k%>)" name="confirmation(<%=k%>)" value="Y" checked disabled>Confirmed<br></td>
<%end if%>
<%if confirmationstatusarray(k) <> True Then%>
<td colspan="1"><input type="checkbox" id = "confirmation(<%=k%>)" name="confirmation(<%=k%>)" value="Y">Confirm<br></td>
<%end if%>

在SQL表中输入复选框值的代码:

enteredby = Session("empno") 'session empno, used for empno & enteredby
  for i = 0 to clientrows
    selectedclientnos = Request.form("selectedclientnos(" & i & ")")
    confirmationcheck = Request.form("confirmation(" & i & ")")

    'set checkbox value in array to 0 if unchecked
    If confirmationcheck = "" Then
    confirmationcheck = "0"
    End If

    if ((confirmationcheck <> "0") and (confirmedby(i) = "")) then 'checks if client offset has not yet been confirmed, and if box has been checked, if so will save session empno
        strSQL = "update Incident_FinancialOffsets set confirmedby = '"&enteredby&"' where incidentid = "&incidentid&" AND cno = '"&selectedclientnos&"';"
        Set rs = objConnection.Execute(strSQL, ,adCmdText)  
        confirmationcheck = 0
    end if
  next

1 个答案:

答案 0 :(得分:0)

我发现没有满足SQL更新的其中一个条件。检查字符串(confirmby)是否为空是不够的,所以我还检查了IsEmpty(由(i)确认)并解决了这个问题。

confirmedby = confirmedby(i)

    if ((confirmationcheck <> "0") and ((IsEmpty(confirmedby) or (confirmedby = "")))) then 'checks if client offset has not yet been confirmed, and if box has been checked, if so will save session empno
        strSQL = "update Incident_FinancialOffsets set confirmedby = '"&enteredby&"' where incidentid = "&incidentid&" AND cno = '"&selectedclientnos&"';"
        Set rs = objConnection.Execute(strSQL, ,adCmdText)  
        confirmationcheck = 0
    end if