All checks you can do before storing in the database the information, for example a form may have mascara that adds the (xx) xxxx-xxxx, but you make a treatment to remove the other characters that are not number, this way storing only number in a varchar in the bank.
Remembering if you want the value checked before sending to confirm that it sends only correct digits, use regular expression to recognize the string something like ([0-9]{2})\s[0-9]{4}-[0-9]{4}
I am not saying that this regular expression is the right one, but it is something very close to what you can use, so it will force you to have two numbers in the DDD between parentheses and 8 consecutive numbers separated by -.
This already guarantees, then a split or a tokenizer depending on what you use to separate and remove what is not a digit, and concatenates all the rest as a number and saves it in the database.
When accessing, to display the data in a visual way only create a mask again to apply on top of the restored value. As database values need to be correct, the treatments who does and always the program to take the value and demonstrate, at least the best way for you to think is this.
Why record the mask?
– Murilo Fechio
I would write only the numbers and apply mask when performing the registration, viewing the query or doing a search.
– Luis Henrique
in another form I will display a table like
DataGridView
from there to be showing with punctuation etc.. Or you can put on a mask? If you can then record without a mask. The problem is that you can’t put onint
because variable int has short size limit– Leonardo
Save both without mask in text type field and when displaying format as you want in output
– Murilo Fechio
ok, but type text field stores letter too, have you do to read only numbers? How
int
andnumeric
?– Leonardo
You do the processing in the field that is receiving this data in c#. You will use what?
TextBox
even normal?– Murilo Fechio
yes yes, just textbox
– Leonardo
http://answall.com/questions/47871/tipo-do-campo-cpf-ou-cnpj-no-banco-de-dados-varchar-ou-int/47873#47873
– Maniero