您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> asp编程 >> 正文

asp 删除指定记录程序代码

作者:佚名    责任编辑:admin    更新时间:2022-06-22

这是一款asp教程 删除指定记录程序代码哦,实例由点击连接到删除页面,并且执行删除,

<%
数据库教程连接
sub opendb()
set rs=server.CreateObject("adodb.recordset")
set conn=server.CreateObject("adodb.connection")
conn.connectionstring="provider=microsoft.jet.oledb.4.0; data source="&server.mappath("datasource/hhinfo.mdb")
conn.open
end sub

判断是否为登陆用户

if session("username")="" and session("userpwd")="" then
response.Redirect("login.html")
end if
dim sql,id

获取Id由地址栏传过来的值

id=html_encode(request.QueryString("id"))
 if id="" or not isnumeric(id) then
  response.Write("非法操作")
 else
  sql="delete * from new where id="&id
  call opendb()
  conn.execute(sql)
  if err=0 then
   response.write("<script>alert('删除成功');location='www.3lian.net/a.asp';</script>")
  else
   response.write("<script>alert('删除失败,服务器忙....');location='new.asp';</script>")
  end if
 end if
%>

使用方法
<a href="http://www.3lian.net/?id=1">删除</a>