标题:请教管理大哥
只看楼主
jz1024
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-8-13
 问题点数:0 回复次数:3 
请教管理大哥
<!--#include file="Connections.asp"-->
<%
Mobile=request("Mobile")
if Mobile="" then
response.write "<script>alert('参数错误');location.href='default.asp';</script>"
response.end
else
sql="delete * from cust where Mobile='"&Mobile&"'"
rs.open sql,conn,1,3
response.write "<script>alert('删除成功');window.close();</script>"
end if
%>



上面的代码只能删除一条记录,怎么循环删除多条查询出来的记录啊。
搜索更多相关主题的帖子: 管理 
2005-08-13 11:05
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5807
专家分:108
注 册:2005-4-7
得分:0 
应该是所有符合条件的都删除了吧?

2005-08-13 14:07
jz1024
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-8-13
得分:0 

<%@ CODEPAGE = "936" %> <!--#include file="Connections.asp" --> <!--#include file="conn.asp" --> <title>删除结果</title> <script language="JavaScript"> <!-- function a(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> <script language="JavaScript"> function test(){ if (document.form2.page.value=="" || isNaN(document.form2.page.value)) { alert("输入页数必须为数值型"); document.form2.page.focus(); return false; } return true; } </script> <script> function del() //用于判断记录有没有选中的函数 { var flag=true; var temp=""; var tmp; if((document.form1.answer.length+"")=="undefined") {tmp=1}else{tmp=document.form1.answer.length} if (tmp==1){ if (document.form1.answer.checked){ flag=false; temp=document.form1.answer.value }}else { for (i=0;i<document.form1.answer.length;i++) { if (document.form1.answer[i].checked){ if (temp=="") { flag=false; temp=document.form1.answer[i].value } else {flag=false; temp = temp +","+ document.form1.answer[i].value }}}} if (flag){ alert("对不起,你还没有选择!")} else {name=document.form1.name.value if (confirm("确定要批量删除?")){ window.location="delt.asp?mobile=" + temp;}} return !flag; } </script> <script language=Javascript> function checkall(all)//用于判断全选记录的函数 { var a = document.getElementsByName("answer"); for (var i=0; i<a.length; i++) a[i].checked = all.checked; } </script>

<div align="center"> <center><form method="POST" id=form1 name=form1> <table wMobileth=363 border="1" cellspacing="0" cellpadding="0" bordercolor="<%=bgcolor%>" width="181" height="98"> <TR > <TD class=tdc1 wMobileth="94%" width="171"><center> <table wMobileth="320" border="1" cellspacing="0" cellpadding="4" style="border-collapse: collapse" bordercolor="<%=bgcolor%>" width="100%"> <tr align="center"> <td height="22" class=tdc1 <%=hColor%>>号码<% If Session("guestbookfeiyue") <> "" Then %>删除<% end if%></td> </tr> </table></center></td> </tr> <tr> <td width="171"> <p align="center"> <% mobile=request("mobile") key=request("key") keys=Split(key,chr(10)) for each onekey in keys %> <td></tr> <tr> <td width="171"> <p align="center"> <input type="checkbox" name="answer" value="<%=onekey%>" id="Checkbox1"> <a href="dele.asp?mobile=<%=onekey%>" target="_blank"><%=onekey%></a><br>

<% set rstopic2 = server.createobject("adodb.recordset") sql = "select * from cust where mobile like '%"&onekey&"%' order by name desc" rstopic2.open sql,conn,1,1 if not(rstopic2.BOF or rstopic2.EOF) then Mobile=rstopic2(0) Memo=rstopic2(1) GroupID=rstopic2(2) Name=rstopic2(3) line=line & Mobile&"|"&Memo&"|"&GroupID&"|"&Name&"" end if set rstopic2=nothing NEXT %><td></tr><tr> <td width="171"><p align="center"> <input type="checkbox" name="chkall" value="on" onclick="checkall(this)" ID="Checkbox2">选中所有 <input type="button" name="btnDelete" value="删除" style='font-family: 宋体; font-size: 9pt;' onclick="del()" ID="Button1"> </td></tr></td></tr> </table></form></div>这些是result.asp的代码! 怎么写删除的delt.asp,就是上面我发的代码怎么修改为批量删除的啊。

2005-08-13 14:53
toolag
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2005-7-30
得分:0 
[QUOTE]sql="delete * from cust where Mobile='"&amp;Mobile&amp;"'"
rs.open sql,conn,1,3
response.write "&lt;script&gt;alert('删除成功');window.close();&lt;/script&gt;"[/QUOTE]

sql="delete from cust where Mobile='"&amp;Mobile&amp;"'"
conn.execute(sql)
response.write "&lt;script&gt;alert('删除成功');window.close();&lt;/script&gt;"
response.end

[此贴子已经被作者于2005-8-13 21:33:14编辑过]



VB, Delphi, ASP, PHP, JSP, .NET MS SQL, My SQL, Oracle Diablo, StarCraft, WarCraft, World of Warcraft
2005-08-13 21:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-25032-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.082356 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved