萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> asp編程 >> asp 刪除指定記錄程序代碼

asp 刪除指定記錄程序代碼

這是一款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>

copyright © 萬盛學電腦網 all rights reserved