asp如何批量更新数据库数据?
答案:1 悬赏:70 手机版
解决时间 2021-04-08 19:16
- 提问者网友:眉目添风霜
- 2021-04-08 06:44
第一个a.asp页面代码:<br><script language=javascript><br>function unselectall()<br>{<br> if(document.th_edit.chkAll.checked){<br> document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;<br> } <br>}<br><br>function CheckAll(form)<br> {<br> for (var i=0;i<form.elements.length;i++)<br> {<br> var e = form.elements[i];<br> if (e.Name != "chkAll")<br> e.checked = form.chkAll.checked;<br> }<br> }<br>function ConfirmDel()<br>{<br> if(confirm("确定要修改吗?"))<br> return true;<br> else<br> return false;<br>}<br></script><br><br></head><br><body><br><%<br>sub_number=request("sub_number")<br>sub_stores=request("sub_stores")<br>set rs=server.CreateObject("ADODB.Recordset")<br>sql="select * from venshop_basket where sub_number='"+sub_number+"'"<br>rs.open sql,conn,1,3<br>%><br><table><br> <tr><br> <td>商品名称</td><br> <td>订购数量</td><br> <td>退货数量</td><br> <td>配送门店</td><br> <td>下单时间</td><br> <td>退货原因</td><br> </tr><br><br><%<br>do while not rs.eof<br>%><br><form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><br> <tr><br> <td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%><br> </td><br> <td><%=rs("basket_count")%></td><br> <td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td><br> <td><%=sub_stores%></td><br> <td><%=rs("basket_date")%></td><br> <td><input type="text" name="yuanyin"></td><br> </tr><br><br> <%<br>rs.movenext<br>loop<br>%><br> <tr><br> <td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td><br> <td><input type="submit" name="tuihuo" value="退货"></td><br> <td></td><br> <td></td><br> <td></td><br> <td></td><br> </tr><br><br></form><br></table><br><%<br>rs.close<br>conn.close<br>set rs=nothing<br>set conn=nothing<br>%><br></body><br></html><br>th_update.asp页面代码就写了这么点,剩下的不会写:<br><br><!--#include file="conn.asp"--><br><!--#include file="ad_chk.asp"--><br><%<br>If Request.Form("delid")="" or isnull(Request.Form("delid")) or isempty(Request.Form("delid")) then<br>response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"<br>else<br>arrdel=Request("delid")<br>basket_count=Request("basket_count") <br>thcount=Request("thcount") <br> sql="update venshop_basket set basket_count='"+thcount+"' where basket_id='"+arrdel+"'" <br> conn.Execute sql <br> set conn=nothing <br> response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>" <br> response.Redirect("ad_sub.asp") <br>end if<br>%><br>这样不是批量修改,只能单独更新,且更新出来的数据也不对,数据库里显示“20,”不知道为什么后面带个逗号。
最佳答案
- 五星知识达人网友:污到你湿
- 2021-04-08 08:21
第一个a.asp页面代码:<br><script language=javascript><br>function unselectall()<br>{<br> if(document.th_edit.chkAll.checked){<br> document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;<br> } <br>}<br><br>function CheckAll(form)<br> {<br> for (var i=0;i<form.elements.length;i++)<br> {<br> var e = form.elements[i];<br> if (e.Name != "chkAll")<br> e.checked = form.chkAll.checked;<br> }<br> }<br>function ConfirmDel()<br>{<br> if(confirm("确定要修改吗?"))<br> return true;<br> else<br> return false;<br>}<br></script><br><br></head><br><body><br><%<br>sub_number=request("sub_number")<br>sub_stores=request("sub_stores")<br>set rs=server.CreateObject("ADODB.Recordset")<br>sql="select * from venshop_basket where sub_number='"+sub_number+"'"<br>rs.open sql,conn,1,3<br>%><br><table><br> <tr><br> <td>商品名称</td><br> <td>订购数量</td><br> <td>退货数量</td><br> <td>配送门店</td><br> <td>下单时间</td><br> <td>退货原因</td><br></tr><br><form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%<br>do while not rs.eof<br>%><br><tr><br><td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%><br> </td><br> <td><%=rs("basket_count")%></td><br> <td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td><br> <td><%=sub_stores%></td><br> <td><%=rs("basket_date")%></td><br> <td><input type="text" name="yuanyin"></td><br> </tr><br> <%<br>rs.movenext<br>loop<br>%><br><tr><br><td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td><br> <td><input type="submit" name="tuihuo" value="退货"></td><br> <td></td><br> <td></td><br> <td></td><br> <td></td><br></tr><br></form><br></table><br><%<br>rs.close<br>conn.close<br>set rs=nothing<br>set conn=nothing<br>%><br></body><br></html><br><br>th_update.asp页面代码:<br><br><!--#include file="conn.asp"--><br><!--#include file="ad_chk.asp"--><br><%<br>If Request("delid") & ""="" then<br>response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"<br>else<br>arrdel=Request("delid")<br>basket_count=Request("basket_count") <br>thcount=Request("thcount")<br>for i=1 to arrdel.count<br> sql="update venshop_basket set basket_count='" & thcount(i) & "' where basket_id='" & arrdel(i) & "'"<br> conn.Execute sql<br>next<br>set conn=nothing <br>response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>" <br> response.Redirect("ad_sub.asp") <br>end if<br>%>
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯