Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to my student id example-140200001
Hear 14 is year 02 is fixcode it is a school id and generate id comming 00001 to 2,3,.....like that but '0000' is also fix digit number
note( In This ID-changeble number is yy its change in year wise and 123... coming as serial number wise.hear '020000' is fix code its not change in this id )
plz help me how to generat....?

i need - ist student id-140200001
then next student id generate-140200002
then next id generet-140200003
then 140200004...... like that
Posted
Updated 24-Aug-14 19:56pm
v2
Comments
Sergey Alexandrovich Kryukov 25-Aug-14 1:14am    
Relational database or what? :-)
—SA

Cannot you simply follow your algorithm? You just need to permanently store (for instance via serialization) the last generated suffix.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Aug-14 1:38am    
Fair enough, a 5, but I would rather keep the unique ID a totally abstract number, leaving the year, school code and other sentimental detail for student profile info. Duplicating any data is a sin. With a relational database, it would be enough to have a primary key of the integer type big enough to enumerate all students in a world. Staying away from all kinds of "school IDs" is good to avoid compromising future flexibility.
—SA
Check a method just pass the parameter year, bla bla and get STUDENTID
string GetObjectID(int sequence, string yr = "14", string d = "02")
  {
      string getZero = "";
      for (int i = 0; i < 5 - sequence.ToString().Length; i++)
      {
          getZero += "0";
      }
      return yr + d + getZero + sequence;
  }


This will return like
for 1 : 140200001
For 10: 140200010
For 99: 140200099
.....
for 999: 140200999
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900