0
代碼似乎更早的工作,我不知道是否進行了更改或者什麼,但現在這是行不通的用於保存複選框值。但是,在頁面加載時檢索舊的保存值沒有問題。任何人都可以看到現在沒有插入值的原因嗎?爲什麼這些asp複選框值不被傳遞給SQL?
代碼複選框:
<%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
我知道這與您的問題無關,但構建您的SQL語句會使您容易受到SQL注入的攻擊。我強烈建議參數化這些SQL語句。 – Snuffleupagus