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

Source: Internet
Author: User

When I was doing something today, found a very strange problem, the database (SQL Server) in the field set the type is ntext, but the saved data is always very short, beginning to think that in a section of the program set a length limit, in the Set breakpoint tracking debugging found that passing data is normal, But the content saved after the storage operation is always very short, number of characters saved 16, the database set the field type ntext length is also 16, so think is not a database of bugs, in Query Analyzer write INSERT statements to test, the results found that the saved content is normal , so the problem must be in the program, and finally check that the parameter type specified when constructing the Parameter object SqlParameter of the SqlCommand command object is ntext and specifies a length of 16, 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.