当前位置: 代码迷 >> ASP >> ASP怎么结束本次for循环继续上次循环
  详细解决方案

ASP怎么结束本次for循环继续上次循环

热度:526   发布时间:2012-08-28 12:37:01.0
ASP如何结束本次for循环继续下次循环
VB code

ArrStudentID=split(request("StudentID"),",")
    '分离出学生学号   
    for   i=0   to   ubound(ArrStudentID)-1
     
      score1=request("Score1"   &   ArrStudentID(i))
      score2=request("Score2"   &   ArrStudentID(i))      
      score3=request("Score3"   &   ArrStudentID(i))      
      score4=request("Score4"   &   ArrStudentID(i))
      score5=request("Score5"   &   ArrStudentID(i))
      score6=request("Score6"   &   ArrStudentID(i))
      score7=request("Score7"   &   ArrStudentID(i))      
    '得到对应学生的输入成绩
if  score1="" and score2="" and score3="" and score4="" and score5="" and score6="" and score7="" then  goto   nextfor
end if
sql = "update 成绩 set " 
if trim(score1) <> "" then sql = sql & " 实验一="&score1
if trim(score2) <> "" then sql = sql & " ,实验二="&score2  
if trim(score3) <> "" then sql = sql & " ,实验三="&score3
if trim(score4) <> "" then sql = sql & " ,实验四="&score4
if trim(score5) <> "" then sql = sql & " ,实验五="&score5
if trim(score6) <> "" then sql = sql & " ,实验六="&score6 
if trim(score7) <> "" then sql = sql & " ,考试="&score7 
sql = sql & " where 课程名='"&session("id1")&"' and 学号='"&ArrStudentID(i)&"'"
response.write(sql)
conn.execute(sql)
nextfor:next  

    %>

提示缺少语句,也不知道错哪里,应该怎么改,只要实现相同功能就行:score1-score7都为空时不执行Update语句,不都为空值时就执行Update!!!!

------解决方案--------------------
ArrStudentID=split(request("StudentID"),",")
'分离出学生学号
for i=0 to ubound(ArrStudentID)-1

score1=request("Score1" & ArrStudentID(i))
score2=request("Score2" & ArrStudentID(i))
score3=request("Score3" & ArrStudentID(i))
score4=request("Score4" & ArrStudentID(i))
score5=request("Score5" & ArrStudentID(i))
score6=request("Score6" & ArrStudentID(i))
score7=request("Score7" & ArrStudentID(i))
if Not CBool(score1="" and score2="" and score3="" and score4="" and score5="" and score6="" and score7="") then
sql = "update 成绩 set " 
if trim(score1) <> "" then sql = sql & " 实验一="&score1
if trim(score2) <> "" then sql = sql & " ,实验二="&score2
if trim(score3) <> "" then sql = sql & " ,实验三="&score3
if trim(score4) <> "" then sql = sql & " ,实验四="&score4
if trim(score5) <> "" then sql = sql & " ,实验五="&score5
if trim(score6) <> "" then sql = sql & " ,实验六="&score6 
if trim(score7) <> "" then sql = sql & " ,考试="&score7 
sql = sql & " where 课程名='"&session("id1")&"' and 学号='"&ArrStudentID(i)&"'"
response.write(sql)
conn.execute(sql)
end if
next
  相关解决方案