(2) How C # ADO solves SQL Injection vulnerability attacks

Source: Internet
Author: User

SQL injection is a way for a user to submit an SQL statement to the server via a client request Get or post, and spoof the servers to execute a malicious SQL statement. For example, the following SQL statement:
1 " SELECT * from t_stuff where name = ' "+txtbox1.text+"";
Where Txtbox1 is a TextBox control, we normally enter a name in this TextBox control to query the employee's information. However, if a user maliciously enters a concatenation string in this TextBox control, for example: "1 ' or ' 1 ' = ' 1", then this query statement will look like this:
1 " SELECT * FROM student where name = ' 1 ' or ' 1 ' = ' 1 ' "
In this case, it would be a great hazard to query all the information of all the employees in the database anyway. For this problem, you can use the placeholder method to solve. We made improvements using the Add method of the parameters in the SqlCommand class, with the following code:
1 " SELECT * from student where name [email protected] " ; 2 cmd. Parameters.Add (new SqlParameter ("@name", TextBox1.Text));
◇parameters mechanism mainly in the database of the response column, query whether there is a character after the @, this time again in the TextBox input similar to "1 ' or ' 1 ' = ' 1" character has no effect. The character arguments that follow the ◇@ cannot be used to replace information such as keywords, but can only be used to replace the specific value of an item that exists in the database, that is, the "=" number behind it.

(2) How C # ADO solves SQL Injection vulnerability attacks

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.