1
Reply

Customize Auto-increment ID number... in csharp

Jordan Colcol

Jordan Colcol

Dec 11 2013 9:06 AM
1.3k
Hello, I just want to know how i will auto generate ID number of student using the following format: 1300001 (wherein 06 is the 2 digit year format followed by the ID number.. which start with 00001) ... The scenario is this: I have a textbox named as txtIDNbe o... then lets say the database is ready for saving record (meaning no record is still existing..) then If  the user add the first student record... we should see first if there is existing record, if no record exist then we create the id number of the 1st record to start with 1300001... otherwise, if record is already existing database (assuming there is 2 record that is already inserted(1300001 & 1300002)) then we count the number of record   and increment the ID number by 1... so the next id number will be 1300003 and so on....
My problem is What is the csharp code of this?..... i am using SQL Server 2008..... Thanks and God Bless Us All..... :-) I do hope you can help me with is one...

Answers (1)