user1882705
user1882705

Reputation: 1081

Auto generation of a sequence number in c# or SQL

I have a situation where user enters a number of length 9 digits. But some people will only enter three digits like 901. So when they enter three digits in the text box, i have to auto generate the rest of the 6 digits and insert it into the database. I should check this against data base table that what was the last auto generated number with 901 and insert next value to it. I just need a suggestion not the complete solution, that i should do this c# or SQL. Which is the best way to do it.

Thanks

Upvotes: 0

Views: 1310

Answers (1)

David J Barnes
David J Barnes

Reputation: 506

A few things. As Tim mentioned, seems the system should provide the user with the number, not the user providing the system with the number. At any rate you'll want to use a database which would at the least contain a series of primary keys [http://en.wikipedia.org/wiki/Unique_key] (numbers not to be duplicated). Se the key to auto increment. This will ensure no other user has the same number/id.

Upvotes: 1

Related Questions