日期:2014-05-17  浏览次数:21109 次

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