Board index » delphi » How to ensure a char field is always filled

How to ensure a char field is always filled

SQL2000 and Delphi 6

I have a DBGrid and a table with a char(4) column, where pin's are entered.
How can I set up constraints so that ALL 4 characters are required?
How can I make sure only digits are accepted?

Thanks,
Anders Johansson

 

Re:How to ensure a char field is always filled


Probably easier to us a field edit mask, with so beforepost logic.

Quote
"Anders Johansson" <anders.johans...@NOSPAMrangeservant.se> wrote in message

news:3da3f3a7$1@newsgroups.borland.com...
Quote
> SQL2000 and Delphi 6

> I have a DBGrid and a table with a char(4) column, where pin's are
entered.
> How can I set up constraints so that ALL 4 characters are required?
> How can I make sure only digits are accepted?

> Thanks,
> Anders Johansson

Re:How to ensure a char field is always filled


Quote
"Anders Johansson" <anders.johans...@NOSPAMrangeservant.se> wrote in message

news:3da3f3a7$1@newsgroups.borland.com...
Quote
> SQL2000 and Delphi 6

> I have a DBGrid and a table with a char(4) column, where pin's are
entered.
> How can I set up constraints so that ALL 4 characters are required?
> How can I make sure only digits are accepted?

> Thanks,
> Anders Johansson

Anders,

Couldn't you use a constraint that checks that length of the item is 4
(t{*word*220} both sides within the len() function), then check to see if it's
numeric. If thery' ok, check for a decimal seperator in the data, and if
it's not there, then the data is ok otherwise fail.

example of check constraint (Untested, assume field name is PIN)
len(ltrim([PIN])) = 4 and isnumeric([PIN]) = 1 and charindex('.',[PIN]) = 0

Mike Walsh

Other Threads