Strings in the .NET Framework support a wide array of
character sets and languages. This is good because SQL Server can support different languages and cultures. However, the .NET Framework does not validate the
requirement on the length of the string This means that even though the length
of a field in SQL Server is 50 characters long, the .NET Framework string type
cannot be limited by that.
It is important to validate the lengths of strings before
passing them to the database. This can be troublesome because the error message
that returns to the caller is usually not specific enough to identify the
specific field over the limit, and it becomes a harder task to identify the
data in error.
The UI controls in .NET allow restrictions on the lengths of
strings by entering in a maximum limit. A check on the server side can be done
as well; though hard-coding a string length can make it difficult to maintain
an application (because any changes to the database affect the UI).