Asp database tutorial record deletion is actually very easy to do in asp. As long as you connect to the database, then use the sql delete function to delete it. Let's take a look at an example. Delete a single record
Copy the code code as follows:
id = saferequest(id)
sql=delete from table1 where whereid>&id&
rs.open sql,conn,1,3
response.write <script>alert('Deletion successful');location.href='del.asp';</script>
set rs=nothing
set conn=nothing
This is a function to filter illegal characters
Copy the code code as follows:
function saferequest(paraname)
dimparavalue
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 Please do not add illegal characters to the function!
response.end
else
saferequest=paravalue
end if
end function
Batch deletion method:
Mainly achieved by using for loop.
Copy the code code as follows:
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