asp关联数据库后如何删除数据库中的一条数据?
<%setconnection=server.createobject("ADODB.connection")Connection.Open("driver={SQLSe...
<%
set connection=server.createobject("ADODB.connection")
Connection.Open("driver={SQL Server};database=pubs;"&_
"server=172.16.57.22;uid=sa;pwd=")
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM txl ORDER BY tID DESC"
rs.Open sql, connection, 3
这是链接代码。删除记录的代码 展开
set connection=server.createobject("ADODB.connection")
Connection.Open("driver={SQL Server};database=pubs;"&_
"server=172.16.57.22;uid=sa;pwd=")
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM txl ORDER BY tID DESC"
rs.Open sql, connection, 3
这是链接代码。删除记录的代码 展开
2个回答
展开全部
图片中的那个页面上的“删除”二字的代码:
<a onclick="javascript:if(!confirm('确定要删除吗?')) { return false; }" href="delete.asp?id=<%=rs("id")%>">删除</a>
这代码是让点击删除时,弹出对话框询问确定要删除吗,如果点确定,则会转到delete.asp页面。
delete.asp页面代码:
<%
id=Cint(Request.QueryString("id"))
set connection=server.createobject("ADODB.connection")
Connection.Open("driver={SQL Server};database=pubs;"&_ "server=172.16.57.22;uid=sa;pwd=")
sql = "delete * From txl where id="&id
Conn.Execute(sql)
Response.write("<p align=center>该文章已删除!<p>")
conn.close
set conn=nothing
%>
<script language="javascript">
setTimeout("history.go(-1)",2000);
</script>
<a onclick="javascript:if(!confirm('确定要删除吗?')) { return false; }" href="delete.asp?id=<%=rs("id")%>">删除</a>
这代码是让点击删除时,弹出对话框询问确定要删除吗,如果点确定,则会转到delete.asp页面。
delete.asp页面代码:
<%
id=Cint(Request.QueryString("id"))
set connection=server.createobject("ADODB.connection")
Connection.Open("driver={SQL Server};database=pubs;"&_ "server=172.16.57.22;uid=sa;pwd=")
sql = "delete * From txl where id="&id
Conn.Execute(sql)
Response.write("<p align=center>该文章已删除!<p>")
conn.close
set conn=nothing
%>
<script language="javascript">
setTimeout("history.go(-1)",2000);
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询