在传统的ASP循环更新语句 [英] loop update statement in classic asp
本文介绍了在传统的ASP循环更新语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我真的需要一些帮助,这code。该循环仅在进行更新语句时,有可能4条选择,以便它具有循环4次运行一次。这是第1次香港专业教育学院遇到这个问题,我似乎明白为什么它是这样做这样。请帮忙。谢谢你。
<! - #include文件=connectionString.inc - >
<%
昏暗strmode,arrmode,我,RS,SQLstr,A,B,site_to
strmode = REQUEST.FORM(changeBox)
CONT1 =的Request.Form(CONT1)
arrmode =拆分(strmode,,)
如果的request.form(submitChange)=然后
回复于(请再试一次,你没有选择任何东西。preSS回到你的浏览器)
万一
如果的request.form(submitChange)=网站,然后
的Response.Write(二)
对于i = 0 UBound函数(arrmode)
SQLstr =UPDATE SCSer SET Ser_Site_Num ='&放大器;的request.form(site_to)及'WHERE Ser_Num ='&放大器; arrmode(ⅰ)及'
集RS =的Server.CreateObject(ADODB.Recordset)
rs.open SQLstr,康涅狄格州,1,2
的Response.Write(更新成功!+ arrmode(I))
下一个
万一如果的request.form(submitChange)=合同则
A = LBOUND(arrmode)
B = UBound函数(arrmode)
SQLstr =UPDATE SCSer SET Ser_Site_Num ='&放大器;的request.form(site_to)及'WHERE Ser_Num BETWEEN'&放大器; arrmode(一)及'和'&放大器; arrmode(B)及'
集RS =的Server.CreateObject(ADODB.Recordset)
rs.open SQLstr,康涅狄格州,1,2
的Response.Write(更新成功<!BR />中)
回复于(arrmode(A)+&所述峰; br />中)
的Response.Write(arrmode(b)条)
万一
%GT;
解决方案
试试这个,看看有什么回应说:
<%
昏暗strmode,arrmode,我,RS,SQLstr,A,B,site_to
昏暗oConnstrmode = REQUEST.FORM(changeBox)
CONT1 =的Request.Form(CONT1)
arrmode =拆分(strmode,,)的Response.WritesubmitChange是:&放大器;的request.form(submitChange)及< BR>中
如果的request.form(submitChange)=然后
回复于(请再试一次,你没有选择任何东西。preSS回到你的浏览器)
到Response.End
万一设置oConn =的Server.CreateObject(ADODB.Connection)
oConn.Open康恩如果的request.form(submitChange)=网站,然后
对于i = 0 UBound函数(arrmode)
SQLstr =UPDATE SCSer SET Ser_Site_Num ='&放大器;的request.form(site_to)及'WHERE Ser_Num ='&放大器; TRIM(arrmode(I))及'
的Response.Write执行SQL:&放大器; SQLstr&安培;< BR>中
oConn.Execute(SQLstr)
的Response.Write(更新成功!+ arrmode(I))
下一个
万一如果的request.form(submitChange)=合同则
A = LBOUND(arrmode)
B = UBound函数(arrmode)
SQLstr =UPDATE SCSer SET Ser_Site_Num ='&放大器;的request.form(site_to)及'WHERE转换(INT,Ser_Num)之间的&放大器; arrmode(一)及和&放大器; arrmode(B)及
的Response.Write执行SQL:&放大器; SQLstr&安培;< BR>中
oConn.Execute(SQLstr)
的Response.Write(更新成功<!BR />中)
回复于(arrmode(A)+&所述峰; br />中)
的Response.Write(arrmode(b)条)
万一
%GT;
I really need some help with this code. The loop is only making the update statement run once when there are maybe 4 records chosen so it has to loop 4 times. This is the 1st time ive come across this problem and I cant seem to see why it is doing it like that. Please help. Thank you.
<!--#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
%>
解决方案
Try this and see what the response says:
<%
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
%>
这篇关于在传统的ASP循环更新语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文