asp如何批量更新数据库数据?
第一个a.asp页面代码:<scriptlanguage=javascript>functionunselectall(){if(document.th_edit.chk...
第一个a.asp页面代码:
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<%
do while not rs.eof
%>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();">
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码就写了这么点,剩下的不会写:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request.Form("delid")="" or isnull(Request.Form("delid")) or isempty(Request.Form("delid")) then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
arrdel=Request("delid")
basket_count=Request("basket_count")
thcount=Request("thcount")
sql="update venshop_basket set basket_count='"+thcount+"' where basket_id='"+arrdel+"'"
conn.Execute sql
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%>
这样不是批量修改,只能单独更新,且更新出来的数据也不对,数据库里显示“20,”不知道为什么后面带个逗号。 展开
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<%
do while not rs.eof
%>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();">
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码就写了这么点,剩下的不会写:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request.Form("delid")="" or isnull(Request.Form("delid")) or isempty(Request.Form("delid")) then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
arrdel=Request("delid")
basket_count=Request("basket_count")
thcount=Request("thcount")
sql="update venshop_basket set basket_count='"+thcount+"' where basket_id='"+arrdel+"'"
conn.Execute sql
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%>
这样不是批量修改,只能单独更新,且更新出来的数据也不对,数据库里显示“20,”不知道为什么后面带个逗号。 展开
展开全部
第一个a.asp页面代码:
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%
do while not rs.eof
%>
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request("delid") & ""="" then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
arrdel=Request("delid")
basket_count=Request("basket_count")
thcount=Request("thcount")
for i=1 to arrdel.count
sql="update venshop_basket set basket_count='" & thcount(i) & "' where basket_id='" & arrdel(i) & "'"
conn.Execute sql
next
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%>
<script language=javascript>
function unselectall()
{
if(document.th_edit.chkAll.checked){
document.th_edit.chkAll.checked = document.th_edit.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要修改吗?"))
return true;
else
return false;
}
</script>
</head>
<body>
<%
sub_number=request("sub_number")
sub_stores=request("sub_stores")
set rs=server.CreateObject("ADODB.Recordset")
sql="select * from venshop_basket where sub_number='"+sub_number+"'"
rs.open sql,conn,1,3
%>
<table>
<tr>
<td>商品名称</td>
<td>订购数量</td>
<td>退货数量</td>
<td>配送门店</td>
<td>下单时间</td>
<td>退货原因</td>
</tr>
<form action="th_update.asp" name="th_edit" method="post" onSubmit="return ConfirmDel();"><%
do while not rs.eof
%>
<tr>
<td><input name="delid" type="checkbox" onClick="unselectall()" id="delid" value='<%=cstr(rs("basket_id"))%>'><%=rs("hw_name")%>
</td>
<td><%=rs("basket_count")%></td>
<td><input type="text" name="thcount" value='<%=rs("basket_count")%>'></td>
<td><%=sub_stores%></td>
<td><%=rs("basket_date")%></td>
<td><input type="text" name="yuanyin"></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox" />全选</td>
<td><input type="submit" name="tuihuo" value="退货"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</form>
</table>
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
</body>
</html>
th_update.asp页面代码:
<!--#include file="conn.asp"-->
<!--#include file="ad_chk.asp"-->
<%
If Request("delid") & ""="" then
response.write "<script>alert('请选择要修改的信息!');history.go(-1);</script>"
else
arrdel=Request("delid")
basket_count=Request("basket_count")
thcount=Request("thcount")
for i=1 to arrdel.count
sql="update venshop_basket set basket_count='" & thcount(i) & "' where basket_id='" & arrdel(i) & "'"
conn.Execute sql
next
set conn=nothing
response.write "<script language=JavaScript>alert('修改成功!');location.href=ad_sub.asp;<script>"
response.Redirect("ad_sub.asp")
end if
%>
追问
还是没有更新,也没报错~
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询