各位高手请帮我解释下批量删除的代码,谢谢
asp吧
全部回复
仅看楼主
level 1
pan1990109 楼主
id=request.form("checkbox")
id=Split(id,",")
shu=0
for i=0 to UBound(id)
sql="select * from stu_info_book where user="&user(i)
set rs=conn.execute(sql)
if not rs.eof then
delete_file(rs("fname"))
end if
rs.close
set rs=nothing
sql="delete from stu_info_book where user="&user(i)     
conn.execute sql,shu1
shu=shu+1
next   
if shu>0 then
response.Write("<script>alert('删除成功');location.href='student_mg';</script>")
else
response.write("<Script>alert('删除失败');javascript: history.back();</script>")
end if
conn.close
set conn=nothing
2011年05月07日 16点05分 1
level 6
代码太复杂也不好,这样的好
id=request.form("checkbox") '得到要删除的id
sql="delete from stu_info_book where user in("&id&")" '删除语句
conn.execute(sql) '执行语句
response.Write("<script>alert('删除成功');location.href='student_mg';</script>")

2011年05月09日 05点05分 2
这里使用 in 的前提是做好了防注入。否则 SQL 注入让人疯狂。
2022年07月30日 03点07分
level 10
2楼方法的确很好,一直以为要循环才行的 原来用in更方便。
2011年05月09日 13点05分 3
吧务
level 14
[呵呵]
2021年02月14日 02点02分 10
[小乖]
2022年08月19日 07点08分
level 8
都是可以的
2021年02月15日 17点02分 11
level 7
曾经我用这个循环方法导致程序死机,后面就用一句in sql就解决了。
2021年02月24日 07点02分 12
吧务
level 14
[小乖]
2022年07月03日 03点07分 13
吧务
level 14
[小乖]
2022年08月08日 02点08分 14
吧务
level 14
[小乖]
2022年11月27日 15点11分 15
1