hi you all, I am creating an application which requres generation of random keys cosisting of 4 numbers(0-9). However, i realized that at some point,the random numbers repeats themselves. how can i avoid this repetition.the numbers form the primary key of a column in sql database table.

Recommended Answers

how are you generating those random numbers.

Jump to Post

All 2 Replies

how are you generating those random numbers.

And why do you go with random number with 4 digits?
Why don't you use an integer + indentity, or GUI or datetime?
4 digits mean your table can hold only up to 9999 records. If you want it to be totally random and impossible for somebody to find the next row by guessing or something, that limits the available number of records dramatically.
What are you coding?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.