0

我真的需要一些关于这段代码的帮助。该循环仅在可能选择 4 条记录时才使更新语句运行一次,因此它必须循环 4 次。这是我第一次遇到这个问题,我似乎不明白为什么会这样。请帮忙。谢谢你。

<!--#include file="connectionString.inc"-->
<%
Dim strmode, arrmode,i,rs,SQLstr, a, b, site_to


strmode=Request.form("changeBox")
cont1=request.form("cont1")
arrmode=split(strmode,",")




if request.form("submitChange") = "" then
    response.write("Please try again, you have no selected anything. Press back on your browser")
end if
   if request.form("submitChange") = "site" then
    response.write(b)
    for i = 0 to UBound(arrmode)
        SQLstr = "UPDATE SCSer SET Ser_Site_Num = '" & request.form("site_to") & "' WHERE Ser_Num = '" & arrmode(i) & "'"
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.open SQLstr, conn, 1, 2       
        Response.Write("SUCCESSFULLY UPDATED! " + arrmode(i))
    next
end if

if request.form("submitChange") = "contract" then
    a=LBound(arrmode)
b=UBound(arrmode)
    SQLstr = "UPDATE SCSer SET Ser_Site_Num = '" & request.form("site_to") & "' WHERE Ser_Num BETWEEN '" & arrmode(a) & "' AND '" & arrmode(b) & "'"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open SQLstr, conn, 1, 2
    Response.Write("SUCCESSFULLY UPDATED! <br/>")
    response.write(arrmode(a)+"<br/>")
    response.write(arrmode(b))
end if
%>
4

1 回答 1

0

试试这个,看看响应是什么:

<%
Dim strmode, arrmode,i,rs,SQLstr, a, b, site_to
Dim oConn

strmode=Request.form("changeBox")
cont1=request.form("cont1")
arrmode=split(strmode,",")

Response.Write "submitChange is:" & request.form("submitChange") & "<br>"


if request.form("submitChange") = "" then
    response.write("Please try again, you have not selected anything. Press back on your browser")
    Response.end
end if

set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open conn

if request.form("submitChange") = "site" then
    for i = 0 to UBound(arrmode)
        SQLstr = "UPDATE SCSer SET Ser_Site_Num = '" & request.form("site_to") & "' WHERE Ser_Num = '" & Trim(arrmode(i)) & "'"
        Response.Write "Executing SQL: "& SQLstr &"<br>"
        oConn.Execute(SQLstr)      
        Response.Write("SUCCESSFULLY UPDATED! " + arrmode(i))
    next
end if

if request.form("submitChange") = "contract" then
    a=LBound(arrmode)
    b=UBound(arrmode)
    SQLstr = "UPDATE SCSer SET Ser_Site_Num = '" & request.form("site_to") & "' WHERE convert(int,Ser_Num) BETWEEN " & arrmode(a) & " AND " & arrmode(b) & ""
    Response.Write "Executing SQL: "& SQLstr &"<br>"
    oConn.Execute(SQLstr)    
    Response.Write("SUCCESSFULLY UPDATED! <br/>")
    response.write(arrmode(a)+"<br/>")
    response.write(arrmode(b))
end if
%>
于 2013-06-06T09:29:23.680 回答