程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> asp 刪除數據庫記錄的代碼

asp 刪除數據庫記錄的代碼

編輯:關於ASP編程
刪除單條記錄
復制代碼 代碼如下:
id = saferequest("id")
sql="delete from table1 where whereid>"&id&""
rs.open sql,conn,1,3
response.write "<script>alert('刪除成功');location.href='del.asp';</script>"
set rs=nothing
set conn=nothing

這是過濾非法字符函數
復制代碼 代碼如下:
function saferequest(paraname)
dim paravalue
paravalue=request(paraname)
if isnumeric(paravalue) = true then
saferequest=paravalue
exit function
elseif instr(lcase(paravalue),"select ") > 0 or instr(lcase(paravalue),"insert ") > 0 or instr(lcase(paravalue),"delete from") > 0 or instr(lcase(paravalue),"count(") > 0 or instr(lcase(paravalue),"drop table") > 0 or instr(lcase(paravalue),"update ") > 0 or instr(lcase(paravalue),"truncate ") > 0 or instr(lcase(paravalue),"asc(") > 0 or instr(lcase(paravalue),"mid(") > 0 or instr(lcase(paravalue),"char(") > 0 or instr(lcase(paravalue),"xp_cmdshell") > 0 or instr(lcase(paravalue),"exec master") > 0 or instr(lcase(paravalue),"net localgroup administrators") > 0 or instr(lcase(paravalue)," and ") > 0 or instr(lcase(paravalue),"net user") > 0 or instr(lcase(paravalue)," or ") > 0 or instr(lcase(paravalue),"""")>0 or instr(lcase(paravalue),"'")>0 then
response.write "請不要在函數中加入非法字符!"
response.end
else
saferequest=paravalue
end if
end function


批量刪除方法:
主要是利用for循環來實現。
復制代碼 代碼如下:
id=request.form("checkbox")
id=Split(id,",")
shu=0
for i=0 to UBound(id)
sql="select * from jiang_fname where id="&id(i)
set rs=conn.execute(sql)
shu=shu+1
next
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved