ASP code for deleting database records

Source: Internet
Author: User

Delete a single record CopyCode The Code is as follows: Id = saferequest ("ID ")
SQL = "delete from Table1 where whereid>" & ID &""
Rs. Open SQL, Conn, 1, 3
Response. Write "<SCRIPT> alert ('deleted successfully'); location. href = 'del. asp '; </SCRIPT>"
Set rs = nothing
Set conn = nothing

This is a function for filtering invalid characters. Copy code The Code is 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 ), "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 invalid characters to the function! "
Response. End
Else
Saferequest = paravalue
End if
End Function

Batch deletion method:
It is mainly implemented using the for loop.Copy codeThe Code is 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 rsw.conn.exe cute (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.