asp删除数据库中的数据
新手学会写入数据库了,但没学会操作数据库。请问如何删除数据库中的数据了?以下是del.asp的内容:<!--#includefile="conn.asp"--><tabl...
新手学会写入数据库了,但没学会操作数据库。
请问如何删除数据库中的数据了?
以下是del.asp的内容:
<!--#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="">删除</a></td>
</tr>
<%
rs.movenext
loop
%>
<%
conn.close
set conn=nothing
end if
%>
</table>
有人说用这个
set rs=server.CreateObject("adodb.recordset")
n=request.form("id")
conn.execute ("delete from news where id="&id)
rs.Close
set rs=nothing
请问这个删除语句写在del.asp哪里地方了。 展开
请问如何删除数据库中的数据了?
以下是del.asp的内容:
<!--#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="">删除</a></td>
</tr>
<%
rs.movenext
loop
%>
<%
conn.close
set conn=nothing
end if
%>
</table>
有人说用这个
set rs=server.CreateObject("adodb.recordset")
n=request.form("id")
conn.execute ("delete from news where id="&id)
rs.Close
set rs=nothing
请问这个删除语句写在del.asp哪里地方了。 展开
2个回答
展开全部
改为:
<!--#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
%>
展开全部
set rs=server.CreateObject("adodb.recordset")
n=request("id")
conn.execute ("delete from photo where id="&id)
rs.Close
set rs=nothing
单独保存一个文件,del1.asp
del.asp中的<td bordercolor="#CCCCCC"><a href="">删除</a></td>改为<td bordercolor="#CCCCCC"><a href="del1.asp?id=<%=rs("id")%>">删除</a></td>
n=request("id")
conn.execute ("delete from photo where id="&id)
rs.Close
set rs=nothing
单独保存一个文件,del1.asp
del.asp中的<td bordercolor="#CCCCCC"><a href="">删除</a></td>改为<td bordercolor="#CCCCCC"><a href="del1.asp?id=<%=rs("id")%>">删除</a></td>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询