How do I Generate a Number in C#
-
Thank u for your answer................ I am not aware of GUID, Can u give idea how to use it
-
HI I run the code with GUID the value is too long "2d89b36d-39fd-4ac7-9cb4-bf0d3768a1c6" I need to display and use only Eight Digits....... pls give some other idea
-
Hi I am creating a Student Registration Form in windows application, i want to generate a Registration Number to the Student after completing the Form. The Number should be unique. Thanks in advance
I would suggest storing the number in a file outside your app and then read that number when processing a form. Once form has been processed just update the number to the next. This is how I currently do it to store version numbers for batch files generated from my apps.
Excellence is doing ordinary things extraordinarily well.
-
HI I run the code with GUID the value is too long "2d89b36d-39fd-4ac7-9cb4-bf0d3768a1c6" I need to display and use only Eight Digits....... pls give some other idea
If you want to add a new student, just get the record from database. For example, the last record is number "10". Then just give number "11" to the new student. It's so easy. The right way is to add a number automatically in database. It increase the number automatically and the number is a primary key. That means the number is unique.
-
I would suggest storing the number in a file outside your app and then read that number when processing a form. Once form has been processed just update the number to the next. This is how I currently do it to store version numbers for batch files generated from my apps.
Excellence is doing ordinary things extraordinarily well.
int i = 1 . . . i = i+1
-
Hi I am creating a Student Registration Form in windows application, i want to generate a Registration Number to the Student after completing the Form. The Number should be unique. Thanks in advance
Are you storing the information in a database? If so, get the database to create the id for you. Make the primary key (the registration number) an identity column and your registration number will be generated upon insertion to the database. If you storing the information in some other manner, you'll need to just build a counter to increase the registration number by some amount (could be 1, could be more in order to validate a number as a valid registration number and avoid typos) each time. If this is a serious application then you'll need to make sure you do this in a common place (singleton) and that this action is threadsafe.
Regards, Rob Philpott.
-
int i = 1 . . . i = i+1
if you close and open it again, then it will start from 1. so it wont work ypki! (for this we have to save it in view state)
Padmanabhan
-
Hi I am creating a Student Registration Form in windows application, i want to generate a Registration Number to the Student after completing the Form. The Number should be unique. Thanks in advance
Rob Philtop is correct.
-
Rob Philtop is correct.
-
J4amieC wrote:
Bob Hilltop? Who's he?
It's not a who it's a where. It's the location of his secret lair.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”