求助:ASP中的查询问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 10:35:28
我做的一个页面上放了个全选复选框,就是一点击全选便将所有的记录都勾选,然后批量删除,但为什么只能一个个的删除,而不能全不删除,它出错提示是:Microsoft JET Database Engine 错误 '80040e14'

语法错误 (逗号) 在查询表达式 'id=25, 23, 22, 21, 16' 中。

/tw/xsy/hdsjxx.asp,行 302

这是我的删除代码:
<% if request("ok1")="删除选中项" then
set rs1=server.CreateObject("adodb.recordset")
sql="select * from sjxx where id="&request("checkbox")
rs1.open sql,conn,3,3
if request("checkbox")="" then
response.Write("<script>alert('请先选择要删除的项目!');history.back();</script>")
else
rs1.delete
response.Write("<script>alert('删除成功!');window.location.href='hdsjxx.asp';</script>")
end if
end if %>

请高手帮忙啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
我用的四楼的办法,虽然没有出错,但全选的时候还是只删除一个啊!
附:修

把sql="select * from sjxx where id="&request("checkbox")
改为:sql="delete from sjxx where id in ("&request("checkbox")&")"
用conn.execute(sql)执行

if request("ok1")="删除选中项" then
if request("checkbox")="" then
response.Write("<script>alert('请先选择要删除的项目!');history.back();</script>")
else

sql="delete from sjxx where id in ("&request("checkbox")&")"

conn.execute(sql)
response.Write("<script>alert('删除成功!');window.location.href='hdsjxx.asp';</script>")
end if
end if

这样子不行吗?

sql语句不支持这样删除,需要做个循环,把id一个个地提取出来再删除

这样改就行了
sql="select * from sjxx where id in ("&request("checkbox")"&)"