In asp.net a situation in which data is automatically intercepted while a stored data operation is being performed

  • 2020-05-05 11:09:21
  • OfStack

When doing the things today, I found a strange problem, the types of fields in a database (SqlServer) for ntext, but saved data is always very short, thought the one set a limit on the length of the program, found in setting a breakpoint tracking debugging in recursive data is very normal, but after the storage operation on preservation is always very short, the content of the number of characters counted the save as 16, database setting the field type ntext length is 16, also so think bug database, to write insert statements in the query analyzer test, It turned out that the saved contents were normal, so the problem must be in the program. Finally, it was checked that when constructing the SqlParameter parameter object of the SqlCommand command object, the parameter type was specified as ntext and the length was specified as 16

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

Remove the length limit, another test, all OK, ha ha, it seems that a lot of things are not very clear concept is very easy to cause problems, I hope this lesson can give me a hint of similar problems in the future friends.

 


Related articles: