asp删除数据
表A和表As,表A字段为A_id和A_from,表As字段为A_id和A_ip,其中表A的A_id和表As的A_ip值相同,应该怎么读取?另外由表As怎么删除表A的数据,...
表A和表As,表A字段为A_id和A_from,表As字段为A_id和A_ip,其中表A的A_id和表As的A_ip值相同,应该怎么读取?另外由表As怎么删除表A的数据,下面的代码错在哪了,谢谢
<!--#include file="conn.asp"-->
<%
if trim(request("action"))="del" then
Conn.Execute("Delete from [A] Where A_ip in ("&request("A_id")&")")
Conn.Execute("Delete from [As] Where A_id in ("&request("A_id")&")")
response.Redirect "AB.asp"
End If
set rs=server.CreateObject("adodb.recordset")
rs.open "select * FROM A order by A_id desc",conn,1,1
do while not rs.eof
%><%
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from As where A_ip=" & rs("A_id"),conn,1,1
do while not rs2.eof
%>
<tr>
<td><%=trim(rs("A_from"))%></td>
<td><%=trim(rs("A_ip"))%></td>
<td><a href="?A_id=<%=rs2("A_id")%>&action=del" >删除</a></td></tr>
<%
rs2.movenext
loop
rs2.close
set rs2=nothing
%><%
rs.movenext
loop
rs.close
set rs=nothing
%> 展开
<!--#include file="conn.asp"-->
<%
if trim(request("action"))="del" then
Conn.Execute("Delete from [A] Where A_ip in ("&request("A_id")&")")
Conn.Execute("Delete from [As] Where A_id in ("&request("A_id")&")")
response.Redirect "AB.asp"
End If
set rs=server.CreateObject("adodb.recordset")
rs.open "select * FROM A order by A_id desc",conn,1,1
do while not rs.eof
%><%
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from As where A_ip=" & rs("A_id"),conn,1,1
do while not rs2.eof
%>
<tr>
<td><%=trim(rs("A_from"))%></td>
<td><%=trim(rs("A_ip"))%></td>
<td><a href="?A_id=<%=rs2("A_id")%>&action=del" >删除</a></td></tr>
<%
rs2.movenext
loop
rs2.close
set rs2=nothing
%><%
rs.movenext
loop
rs.close
set rs=nothing
%> 展开
3个回答
展开全部
假设
你的表A是类别表,
表AS是内容表,那么你要删除表A,即类别.
那么要先打开表A,肯定会传一个值给表A,
Set rS=Conn.execute("Select * from A where A_id="&Request("A_id")&"")
If not Rs.bof and not Rs.eof Then
'如果查到表A有记录,那么就开始先删除表AS里面字段A_Id等于上面那个表的值
Conn.execute("delete from A where A_id in (" & Rs("A_id") &")")
'用in是针对多条记录.
COnn.execute("delete from A where A_id in (" &Request("A_id")&")")
End if
Rs.close
Set Rs=nothing
你的表A是类别表,
表AS是内容表,那么你要删除表A,即类别.
那么要先打开表A,肯定会传一个值给表A,
Set rS=Conn.execute("Select * from A where A_id="&Request("A_id")&"")
If not Rs.bof and not Rs.eof Then
'如果查到表A有记录,那么就开始先删除表AS里面字段A_Id等于上面那个表的值
Conn.execute("delete from A where A_id in (" & Rs("A_id") &")")
'用in是针对多条记录.
COnn.execute("delete from A where A_id in (" &Request("A_id")&")")
End if
Rs.close
Set Rs=nothing
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
改为:
<!--#include file="conn.asp"-->
<table width="93%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>NAME</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>TOOL</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>MINIPHOTO</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>DATA</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>操作</b></td>
</tr>
<%
Set rs=server.createobject("adodb.recordset")
sql="select * from photo order by id desc"
rs.Open sql,conn,1,1
if rs.eof or rs.bof then
response.write ("暂无信息")
else
%>
<%
do while not rs.eof
%>
<tr>
<td bordercolor="#CCCCCC"><%=rs("name")%></td>
<td bordercolor="#CCCCCC"><%=rs("tool")%></td>
<td bordercolor="#CCCCCC"><%=rs("miniphoto")%></td>
<td bordercolor="#CCCCCC"><%=rs("data")%></td>
<td bordercolor="#CCCCCC"><a href="?action=del&id=<%=rs("id")%>">删除</a></td>
</tr>
<%
rs.movenext
loop
%>
<%
conn.close
set conn=nothing
end if
%>
</table>
<%
if request("action")="del" then
set rs=server.CreateObject("adodb.recordset")
n=request.form("id")
conn.execute ("delete from news where id="&id)
rs.Close
set rs=nothing
end if
%>
<!--#include file="conn.asp"-->
<table width="93%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>NAME</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>TOOL</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>MINIPHOTO</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>DATA</b></td>
<td bordercolor="#CCCCCC" bgcolor="#EBEBEB"><b>操作</b></td>
</tr>
<%
Set rs=server.createobject("adodb.recordset")
sql="select * from photo order by id desc"
rs.Open sql,conn,1,1
if rs.eof or rs.bof then
response.write ("暂无信息")
else
%>
<%
do while not rs.eof
%>
<tr>
<td bordercolor="#CCCCCC"><%=rs("name")%></td>
<td bordercolor="#CCCCCC"><%=rs("tool")%></td>
<td bordercolor="#CCCCCC"><%=rs("miniphoto")%></td>
<td bordercolor="#CCCCCC"><%=rs("data")%></td>
<td bordercolor="#CCCCCC"><a href="?action=del&id=<%=rs("id")%>">删除</a></td>
</tr>
<%
rs.movenext
loop
%>
<%
conn.close
set conn=nothing
end if
%>
</table>
<%
if request("action")="del" then
set rs=server.CreateObject("adodb.recordset")
n=request.form("id")
conn.execute ("delete from news where id="&id)
rs.Close
set rs=nothing
end if
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-11-29
展开全部
应该没有太大问题
<%set rs=server.CreateObject(“adodb.recordset“)
rs.Open “select A.*,As.A_ip from A,As where A.A_id=As.A_ip “,conn,1,1
if rs.EOF and rs.BOF then
response.Write “<div align=center><font color=red>还没有分类</font></center>“
paixu=0
else
do while not rs.EOF
%>
<tr>
<td><%=trim(rs(“A_from“))%></td>
<td>
<%=trim(rs(“A_id“))%></td>
<td><a href=“?A_id=<%=rs(“A_id“)%>&action=del“ ><font color=red>删除</font></a></td>
</tr>
<%rs.MoveNext
loop
end if%>
把双引号改下
<%set rs=server.CreateObject(“adodb.recordset“)
rs.Open “select A.*,As.A_ip from A,As where A.A_id=As.A_ip “,conn,1,1
if rs.EOF and rs.BOF then
response.Write “<div align=center><font color=red>还没有分类</font></center>“
paixu=0
else
do while not rs.EOF
%>
<tr>
<td><%=trim(rs(“A_from“))%></td>
<td>
<%=trim(rs(“A_id“))%></td>
<td><a href=“?A_id=<%=rs(“A_id“)%>&action=del“ ><font color=red>删除</font></a></td>
</tr>
<%rs.MoveNext
loop
end if%>
把双引号改下
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询