A situation in which data is automatically intercepted when a stored data operation is performed in a asp.net

Source: Internet
Author: User
asp.net| Data | When doing something today, I found a very strange problem, the type of field set in database (SQL Server) is ntext, but the saved data is always very short, beginning to think that a length limit is set in a section of the program. In the Set breakpoint tracking debugging found that the pass-through data is normal, but after the storage operation is always very short to save the number of characters saved 16, the database Set the field type of ntext is also 16, so think is not a database of bugs, In the Query Analyzer to write the INSERT statement to test, the result found that the contents of the saved is normal, so the problem is certainly in the program, Finally, the parameter type specified when constructing the Parameter object SqlParameter of the SqlCommand command object is ntext and its length is 16 specified, as follows

sqlparameter[] parms = new sqlparameter[] {
New SqlParameter (TemplateID, SqlDbType.Int),
New SqlParameter ("@Content", sqldbtype.ntext,16)
};

The length of the limit to remove, and then a test, all OK, hehe, it seems that a lot of things are not very clear concept is very easy to cause trouble problems, I hope this lesson can give me later also encounter similar problems friends a little hint.



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.