Code _asp Base for ASP to delete database records

Source: Internet
Author: User
Delete a single record
Copy Code code as follows:

id = saferequest ("id")
Sql= "Delete from table1 where whereid>" &id& "
Rs.Open sql,conn,1,3
Response.Write "<script>alert (' delete success '); location.href= ' del.asp ';</script>"
Set rs=nothing
Set conn=nothing

This is the filter illegal character function
Copy Code code as follows:

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), "de Lete from ") > 0 or InStr (LCase (Paravalue)," Count (") > 0 or InStr (LCase (Paravalue)," drop table ") > 0 or InStr (Lcas E (Paravalue), "Update") > 0 or InStr (LCase (Paravalue), "truncate") > 0 or InStr (LCase (Paravalue), "ASC (") > 0 or I Nstr (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


Bulk Deletion method:
This is mainly achieved by using a for loop.
Copy 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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.