If size is not explicitly set in the size parameter, the size is inferred from the value of the DbType parameter.
If you think the above inferred that the size is inferred from the SqlDbType type, then you are wrong, it is actually inferred from the value of the parameter that you passed, such as the value that is passing over is "Shengzhen", the size value is 9, "Shanghai", the size value is 8.
So what kind of results will the different size values cause? The value of size does not simultaneously cause the execution plan of the database to be reused, so that the new execution plan is regenerated every time the SQL is executed, and the database execution time is wasted.
When instantiating SqlParameter, be sure to specify the Size property if it is a character type
For example
New SqlParameter ("@address", SqlDbType.VarChar, 4000)
If you have parameters such as int, Float, bigint,datetime, you can not specify the Size property. However, if size specifies an error, an unpredictable error may occur.
Reference: SqlParameter's Size property http://www.studyofnet.com/news/853.html
This article is from the "Learning also leisure" blog, please be sure to keep this source http://studyofnet.blog.51cto.com/8142094/1682606
The Size property of the SqlParameter