批量处理时,只能更新最新一条信息,求助~急~~
a.ASP中用下拉菜单批量修改
<select name= "foodb <%=oRs( "C_Id ")%> " id= "foodb ">
<option value= "理想 " selected= "selected "> 选择菜系 </option>
<option value= "广东菜 "> 广东菜 </option>
<option value= "福建菜 "> 福建菜 </option>
<option value= "山东菜 "> 山东菜 </option>
<option value= "四川菜 "> 四川菜 </option>
<option value= "湖南菜 "> 湖南菜 </option>
<option value= "江苏菜 "> 江苏菜 </option>
<option value= "浙江菜 "> 浙江菜 </option>
<option value= "安徽菜 "> 安徽菜 </option>
</select>
<input type= "hidden " value= " <%=oRs( "C_Id ")%> " name= "fid " id= "fid " />
b.asp页面进行处理,但是只能更新出最top的一条数据,其他的都没有处理
<%
dim food,eid,fid,nid,i
fid=request.Form( "fid ")
food=request.Form( "foodb ")
response.write food
nid=split(fid, ", ")
eid=ubound(nid)
for i = 0 to eid
sSql= "select C_Foodb from Canteen where C_Id = "&nid(i)& " "
oRs.open sSql,oConn,1,3
response.write sSql
oRs( "C_Foodb ")=request.Form( "foodb "&nid(i))
oRs.update
oRs.close()
Next
response.write " <script LANGUAGE= 'javascript '> alert( '修改成功! ');location.href= 'list_m.asp '; </script> "
%>
麻烦大家看看,还有就是想:当不想处理的数据,在提交完成后,不进行修改,请大家帮帮忙~~~
------解决方案--------------------用SQL语句吧,不要用oRs
for i = 0 to eid
sSql= "update Canteen set C_Foodb= ' " & request.Form( "foodb "&nid(i)) & " ' where C_Id = "&nid(i)& " "
oConn.execute(sSql)
Next
------解决方案--------------------好象没什么错误,依次检查一下传过来的fid , "foodb "&nid(i)吧
------解决方案--------------------select 本来就只传被选中的那个 option 的值,你要都传,最好另外写个 参数 来收集所有值