A condition in asp.net where data is automatically intercepted during data storage operations

Source: Internet
Author: User

When I was doing something today, I found a very strange problem. The field type set in the database (SqlServer) is ntext, but the stored data is always very short, at first, I thought that a length limit was set for a certain segment of the program. When I set resumable tracking and debugging, I found that the data passed through is normal, but after the storage operation is executed, the stored content is always very short, the number of characters saved is 16, and the length of the ntext field set in the database is also 16, so I wonder if it is a database bug, write the insert statement in the query analyzer for testing. The result shows that the stored content is normal, so the problem must be in the program, finally, it is found that the parameter type specified when the SqlParameter parameter object of the SqlCommand object is constructed is ntext and its length is 16. The syntax is as follows:

SqlParameter [] parms = new SqlParameter [] {
New SqlParameter (TEMPLATEID, SqlDbType. Int ),
New SqlParameter ("@ Content", SqlDbType. NText, 16)
};

Remove the length limit and test again. Everything is okay. It seems that the concept of many things is not very clear, and it is easy to cause problems, I hope this lesson will give some tips to my friends who have encountered similar problems in the future.

 

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.