高手请进:请教执行顺序!!!急!等待ing。。。
我写了一段程序,由于牵扯到循环,执行顺序把我搞晕了,请各位高手指点一下,谢谢!!!我想实现这样的功能:循环判断request.form("jsfsh").count个结算方式和提货价都不为空的时候再执行删除,然后再循环执行添加。
但现在我的程序执行顺序是这样的:结算方式和提货价为空时,弹出对话框,返回。但此时数据库中shx='1'的记录已经被删除了。而且当第一条的结算方式和提货价为不为空,第二条的为空时,弹出对话框,返回,但此时第一条的记录在数据库中已经被更新了。(应该是循环做完判断后,在执行下面的程序)
那位高手能指点一下,帮我改一下程序
小弟不胜感激,谢谢!!!
<%sub saveform()%>
<% if request.form("jsfsh").count<>0 then
for j=1 to request.form("jsfsh").count
if request("zbdw")="" then%>
<script language=javascript>
alert( "错误:请选择制表单位!" );
location.href = "javascript:history.back()"
</script>
<%elseif Request.form("jsfsh")(j)="" then%>
<script language=javascript>
alert( "错误:请选择结算方式!" );
location.href = "javascript:history.back()"
</script>
<%elseif Request.form("thj")(j)="" then%>
<script language=javascript>
alert( "错误:请输入提货价!" );
location.href = "javascript:history.back()"
</script>
<% end if
next
sql0="delete from jiage where shx='1'"
conn.execute(sql0)
id=request("id"&i)
qsrq=trim(Request.Form("qsyear"))&"-"&trim(Request.Form("qsmonth"))&"-"&trim(Request.Form("qsday"))
jsrq=trim(Request.Form("jsyear"))&"-"&trim(Request.Form("jsmonth"))&"-"&trim(Request.Form("jsday"))
for i=1 to request.form("jsfsh").count
set rs=server.CreateObject("adodb.recordset")
sql = "select * from jiage where kc_id="+id
rs.Open sql,conn,1,3
rs("chd") = Request.form("jsfsh")(i)
rs("jhj") = Request.form("thj")(i)
rs("qrj") = Request.form("thj")(i)
rs("zbdw") = request("zbdw")
rs("bzh") = request("bzh")(i)
rs("qsrq") = qsrq
rs("jsrq") = jsrq
rs("addtime") = now()
rs("shx") ="1"
rs.Update
rs.Close
set rs=nothing
next
end if
response.write "<p>"
response.write "<div align=center><br><br><br><font color=red>信息添加成功</font><p><a href=kucun.asp>返回</a></div>"
%>
<%end sub%>