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.