Autonumber in MS Access
-
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.
-
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.
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
-
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
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.
-
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.
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
-
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
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.