The value violates the MaxLength limit of this column

  • Thread starter Thread starter Scudder Consulting
  • Start date Start date
S

Scudder Consulting

Im my application is a Winforms C# 2005 front end to a SQL Server 2005
database. I have several phone number fields in which I use a
MaskedTextBox to format the phone number. All is good until I create a new
record and try to save it to the database at which time I get the message
"The value violates the MaxLength limit of this column". The documentation
says that MaskedTextBox does not support the MaxLength property. If I
remove the mask I can save the record. What is going on and how can I fix
this?

Roger
 
It's not the Text Box that is giving you the problem. It's the column in
the database. Your phone number field is probably only 10 digits or so. By
adding in the masking characters you are making the resulting string
greater than what the DB allows. You have two choices. Increase the size of
the field in the database. Or store the data in the database without the
mask.
 
It's not the Text Box that is giving you the problem. It's the column
in the database. Your phone number field is probably only 10 digits or
so. By adding in the masking characters you are making the resulting
string greater than what the DB allows. You have two choices. Increase
the size of the field in the database. Or store the data in the
database without the mask.

Thanks for the help. I want to store the number without the mask. I
thought the mask was only for display... not something that is added to
the data. What do I need to do to prevent the mask character from being
added to the data?

Roger
 
the data. What do I need to do to prevent the mask character from being
added to the data?

Thanks for the help... I found the parameter that determines if the mask
characters are included.

Roher
 
Back
Top