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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Autonumber in MS Access

Autonumber in MS Access

Scheduled Pinned Locked Moved Database
csharpasp-netsaleshelptutorial
5 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.
  • A Offline
    A Offline
    alfakappasigma
    wrote on last edited by
    #1

    Hi everybody, I'm using ASP.NET VB / C# application with MS Access. After successful insertion from my register.aspx page into Customers table, the CustomerID field (autonumber field) gets a randomly generated number which I'm using as the primary key. But sometimes, it generates a negative integer which is not appropriate for using as customer ID. Can anyone suggest me how to get only a postive integer. Also, it doesn't always generate a fixed-length integer. I want to be able to generate a customer ID with a fixed length. Please do suggest me a solution on these issues. Is there an alternative way to generate this non-negative, fixed-length, unique customer ID through .aspx page itself? Could you help me with code please! Thank you. Anjani Shiwakoti Computer programs and social cultures are the same.

    P 1 Reply Last reply
    0
    • A alfakappasigma

      Hi everybody, I'm using ASP.NET VB / C# application with MS Access. After successful insertion from my register.aspx page into Customers table, the CustomerID field (autonumber field) gets a randomly generated number which I'm using as the primary key. But sometimes, it generates a negative integer which is not appropriate for using as customer ID. Can anyone suggest me how to get only a postive integer. Also, it doesn't always generate a fixed-length integer. I want to be able to generate a customer ID with a fixed length. Please do suggest me a solution on these issues. Is there an alternative way to generate this non-negative, fixed-length, unique customer ID through .aspx page itself? Could you help me with code please! Thank you. Anjani Shiwakoti Computer programs and social cultures are the same.

      P Offline
      P Offline
      Pankaj Kulkarni
      wrote on last edited by
      #2

      Hi, If you don't want Randomly Generated Number then The primary key i.e. CustomerID Datatype should be Long Integer/Double. Having "Increment" property set to 'Yes' with Increment Seed '1'. Pankaj Kulkarni -- modified at 0:50 Tuesday 31st January, 2006

      A 1 Reply Last reply
      0
      • P Pankaj Kulkarni

        Hi, If you don't want Randomly Generated Number then The primary key i.e. CustomerID Datatype should be Long Integer/Double. Having "Increment" property set to 'Yes' with Increment Seed '1'. Pankaj Kulkarni -- modified at 0:50 Tuesday 31st January, 2006

        A Offline
        A Offline
        alfakappasigma
        wrote on last edited by
        #3

        Hi Pankaj, While I do appreciate your suggesting using increment property instead of random, I've tried that before but I decided to use random number as customer ID because those random numbers are hard to guess and they can be used to retrieve customer's password in case he/she forgets one. My only problem is sometimes the autonumber creates negative integers, and also the numbers aren't always of a fixed length. If you (or anyone else reading this) could suggest me a better solution, I'd greatly appreciate it. Thanks. Anjani Shiwakoti Computer programs and social cultures are the same.

        L 1 Reply Last reply
        0
        • A alfakappasigma

          Hi Pankaj, While I do appreciate your suggesting using increment property instead of random, I've tried that before but I decided to use random number as customer ID because those random numbers are hard to guess and they can be used to retrieve customer's password in case he/she forgets one. My only problem is sometimes the autonumber creates negative integers, and also the numbers aren't always of a fixed length. If you (or anyone else reading this) could suggest me a better solution, I'd greatly appreciate it. Thanks. Anjani Shiwakoti Computer programs and social cultures are the same.

          L Offline
          L Offline
          Luis Alonso Ramos
          wrote on last edited by
          #4

          And what happens if suddenly you get a random number that already exists? Use an autonumber column and keep the ID private to the application. And to let the user retrieve his password, ask him for an email address during signup and send it to that email address. -- LuisR


          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

          The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

          A 1 Reply Last reply
          0
          • L Luis Alonso Ramos

            And what happens if suddenly you get a random number that already exists? Use an autonumber column and keep the ID private to the application. And to let the user retrieve his password, ask him for an email address during signup and send it to that email address. -- LuisR


            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

            The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

            A Offline
            A Offline
            alfakappasigma
            wrote on last edited by
            #5

            Hi Luis, While I do appreciate your suggestion, I've decided to seed a random postive integer with a fixed length right from my .aspx page, instead of letting MS Access create it for me. I guess that takes care of it. BTW, I don't think that random autnumber will 'suddenly' create a number that already exists in the database. It guarantees that every number it creates will be unique. Anjani Computer programs and social cultures are the same.

            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