ASP SQL anti-injection method _jquery

Source: Internet
Author: User
Tags anti sql injection object model sql injection sql injection attack
Here we will introduce another way to prevent SQL injection attack in ASP, this method is not only applicable in ASP, in fact, in any language that uses ADO object model to interact with database, it may be more appropriate to say that the method of anti SQL injection based on ADO object model is accurate. All right, let's talk about the code.
Copy Code code as follows:

Dim Conn,cmd,pra
Set Conn=server.createobject ("Adodb.connection")
Conn. Open "..... ..." ' This omits the database connection Word

Set Cmd=server.createobject ("Adodb.command")
Set Pra=server.createobject ("ADODB. Parameter ")
Cmd. ActiveConnection = conn

Cmd.commandtext = "Update news set title=?" WHERE id =? "
Cmd.commandtype = adCmdText

Set pra = cmd. CreateParameter ("title", adVarWChar, adParamInput, 50, "1 ' 2 ' 3")
Cmd. Parameters.Append PRA

Set pra = cmd. CreateParameter ("id", adinteger, adParamInput,, 10)
Cmd. Parameters.Append PRA

Cmd. Execute

The ID field of the News table is an integer, the title field is nvarchar (50), and the result is to change the contents of the title field of the record in the News table ID field to 10 to "1 ' 2 ' 3"
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.