Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem on genaration of unique number

problem on genaration of unique number

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpdatabasehelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    biswa47
    wrote on last edited by
    #1

    have a table in sqlserver2005 named emp. where the coloumns of the emp table are as follows. empid char(3), empname varchar(20), empaddrs varchar(20), empDOB dateandtime, emp_no varchar(10) i want to genertae emp_no as autogenertaed sequencitial number. where the format of the auto genertaed number for emp_no will be - "id-yyyy-nnnn" where 1st 2 places are the no of his emp_id i.e 01 or 02 like that 2nd four palces are the year of DOB i.e 2001,or 20005 like this next four places are the numbers i.e 0001 ,0002 like this(it should be sequential number). example of auto generated number are-0120010001,0219990002, 0320000003.and so on.. how will i generate this type of sequential no in asp .net (backend vb.net.) when ever i save a record for a particular employee after giving the data in the front end of their corresponding textboxes, the emp_no should be generated in the database and stored in the emp_no coloumn of emp table. (i know only how to generate auto num.by setting its identity to true.but dont know what to write in the formula filed so that i can genrate the above type of auto generated number) ya i have taken emp_id as char(3) so that while i entry the value 01 in the front end it should be taken as 01 not1. if i will take emp_id as int then if i input 01 it wil take 1 only. thats why i have taken as char. No emp_id is not a sequential no..it can be any number.. thanks in advance

    F P 2 Replies Last reply
    0
    • B biswa47

      have a table in sqlserver2005 named emp. where the coloumns of the emp table are as follows. empid char(3), empname varchar(20), empaddrs varchar(20), empDOB dateandtime, emp_no varchar(10) i want to genertae emp_no as autogenertaed sequencitial number. where the format of the auto genertaed number for emp_no will be - "id-yyyy-nnnn" where 1st 2 places are the no of his emp_id i.e 01 or 02 like that 2nd four palces are the year of DOB i.e 2001,or 20005 like this next four places are the numbers i.e 0001 ,0002 like this(it should be sequential number). example of auto generated number are-0120010001,0219990002, 0320000003.and so on.. how will i generate this type of sequential no in asp .net (backend vb.net.) when ever i save a record for a particular employee after giving the data in the front end of their corresponding textboxes, the emp_no should be generated in the database and stored in the emp_no coloumn of emp table. (i know only how to generate auto num.by setting its identity to true.but dont know what to write in the formula filed so that i can genrate the above type of auto generated number) ya i have taken emp_id as char(3) so that while i entry the value 01 in the front end it should be taken as 01 not1. if i will take emp_id as int then if i input 01 it wil take 1 only. thats why i have taken as char. No emp_id is not a sequential no..it can be any number.. thanks in advance

      F Offline
      F Offline
      Fred_Smith
      wrote on last edited by
      #2

      I would seriously suggest that you re-think your approach to this. Make your empid an autogenerated integer, and then use the ToString() methods to write this with leading zeroes to create an emp_no string

      1 Reply Last reply
      0
      • B biswa47

        have a table in sqlserver2005 named emp. where the coloumns of the emp table are as follows. empid char(3), empname varchar(20), empaddrs varchar(20), empDOB dateandtime, emp_no varchar(10) i want to genertae emp_no as autogenertaed sequencitial number. where the format of the auto genertaed number for emp_no will be - "id-yyyy-nnnn" where 1st 2 places are the no of his emp_id i.e 01 or 02 like that 2nd four palces are the year of DOB i.e 2001,or 20005 like this next four places are the numbers i.e 0001 ,0002 like this(it should be sequential number). example of auto generated number are-0120010001,0219990002, 0320000003.and so on.. how will i generate this type of sequential no in asp .net (backend vb.net.) when ever i save a record for a particular employee after giving the data in the front end of their corresponding textboxes, the emp_no should be generated in the database and stored in the emp_no coloumn of emp table. (i know only how to generate auto num.by setting its identity to true.but dont know what to write in the formula filed so that i can genrate the above type of auto generated number) ya i have taken emp_id as char(3) so that while i entry the value 01 in the front end it should be taken as 01 not1. if i will take emp_id as int then if i input 01 it wil take 1 only. thats why i have taken as char. No emp_id is not a sequential no..it can be any number.. thanks in advance

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        I saw this problem posted here not long ago. Is this a homework assignment by any chance?

        Deja View - the feeling that you've seen this post before.

        B 1 Reply Last reply
        0
        • P Pete OHanlon

          I saw this problem posted here not long ago. Is this a homework assignment by any chance?

          Deja View - the feeling that you've seen this post before.

          B Offline
          B Offline
          biswa47
          wrote on last edited by
          #4

          ya i have posted this a weeks ago? but that time i dint get any solution for this ???? so posted it again.. so could u help me plz...

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups