Precautions for obtaining varchar/nvarchar data in the database

Source: Internet
Author: User

When you obtain the data of a field in the database table in the background of the page, pay attention to the data type. It prevents space placeholders because the character length of the actual data cannot reach the character length specified by the specified data type.

For example:

The structure of a table in MSSQL is as follows:

Table data:

When a user name or password (userPwd) is obtained from the table, if the retrieved data is judged as a condition, it is best to Trim () the data obtained, remove space placeholders on both sides of the data

For example:

Before Trim () is processed, the data obtained from the database is subject to space placeholders due to insufficient data length.

 

After Trim () processing data, the placeholder is cleared.

 

 

 

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.