473,323 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Generate a unique receipt number

I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the application.

My requirements are these:

1. The receipt number must be unique (like a guid is unique)
2. The receipt must be NON sequential.
3. If possible, I'd like it to be 10 to 12 characters long.
4. If possible, I'd like to include only uppercase letters/digits (A-Z,
0-9)

The reason I want the length to be somewhat short is because I don't want
to burden the customer with a long receipt number. There may be a web page
that allows the customer to "track" the job and I don't want them to have
to enter some really long string.

What I'm looking for is similar to a fedex tracking number. These seem to
be non-sequential and must be unique. They are about 10 to 12 digits long.

I have been experimenting with classes in thue System.Security.Cryptography
namespace as well as the various hash routines but haven't, as yet,
disconvered the "magic bullet".

Can anyone push me in the right direction?

Thanks,

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #1
2 4484
You can't have a string that is globally unique and shorter than a GUID.
Why would they make GUIDs so long if they didn't need to be? Fed Ex
tracking numbers aren't globally unique and it sounds like you don't really
need something that is unique like a guid is unique.

You could generate a random number between 1 and 36 and use that number as
an index into an array of A-Z and 0-9. Do that 10-12 times and you'll have
a fairly unique string. You could keep a database of the previously
generated strings to compare against. If on the rare occassion, you
generate one that was already used, you just generate another one.
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1v*****************************@40tude.net...
I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the application.

My requirements are these:

1. The receipt number must be unique (like a guid is unique)
2. The receipt must be NON sequential.
3. If possible, I'd like it to be 10 to 12 characters long.
4. If possible, I'd like to include only uppercase letters/digits (A-Z,
0-9)

The reason I want the length to be somewhat short is because I don't want
to burden the customer with a long receipt number. There may be a web page that allows the customer to "track" the job and I don't want them to have
to enter some really long string.

What I'm looking for is similar to a fedex tracking number. These seem to
be non-sequential and must be unique. They are about 10 to 12 digits long.
I have been experimenting with classes in thue System.Security.Cryptography namespace as well as the various hash routines but haven't, as yet,
disconvered the "magic bullet".

Can anyone push me in the right direction?

Thanks,

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #2
You can't have a string that is globally unique and shorter than a GUID.
Why would they make GUIDs so long if they didn't need to be? Fed Ex
tracking numbers aren't globally unique and it sounds like you don't really
need something that is unique like a guid is unique.

You could generate a random number between 1 and 36 and use that number as
an index into an array of A-Z and 0-9. Do that 10-12 times and you'll have
a fairly unique string. You could keep a database of the previously
generated strings to compare against. If on the rare occassion, you
generate one that was already used, you just generate another one.
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1v*****************************@40tude.net...
I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the application.

My requirements are these:

1. The receipt number must be unique (like a guid is unique)
2. The receipt must be NON sequential.
3. If possible, I'd like it to be 10 to 12 characters long.
4. If possible, I'd like to include only uppercase letters/digits (A-Z,
0-9)

The reason I want the length to be somewhat short is because I don't want
to burden the customer with a long receipt number. There may be a web page that allows the customer to "track" the job and I don't want them to have
to enter some really long string.

What I'm looking for is similar to a fedex tracking number. These seem to
be non-sequential and must be unique. They are about 10 to 12 digits long.
I have been experimenting with classes in thue System.Security.Cryptography namespace as well as the various hash routines but haven't, as yet,
disconvered the "magic bullet".

Can anyone push me in the right direction?

Thanks,

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mullin | last post by:
I need to generate a unique no. in the format like yyyymmddxxxxxx (xxxxxx 6-digitl running number) I think of create a table with two columns date value 20050405 120 20050406 99...
10
by: Mamuninfo | last post by:
Hello, Have any function in the DB2 database that can generate unique id for each string like oracle, mysql,sybase,sqlserver database. In mysql:- select md5(concat_ws("Row name")) from...
2
by: Chris Dunaway | last post by:
I have a web service which is accessed by a windows forms application. When the application submits a unit of work (a "job"), I want to return a job receipt or tracking number back to the...
28
by: Nina | last post by:
I need to generate unique id for my application. Use system time to create id, which is the best fit, but I don't know how to do it. Please help. Thanks in advance for any input.
16
by: Mark S. | last post by:
I'm a fan of the GUID, but the current project is looking to use a genuinely unique integer. Does the following do that? Math.Abs(System.Guid.NewGuid().GetHashCode()) TIA
15
by: Ashish Khandelwal | last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so could any one suggest me that how to generate a unique Hash Code for same string always, and generate different-2 Hash Code...
4
by: gaurav1983 | last post by:
i have to generate unique combinations of given number of digits entered by user eg: N=4 (0,1,2,3) output should be 0 1 2 3
1
by: situ | last post by:
Hi, I'm using DB2 V9 for windows I'm inserting records into DGTT from select statement; the problem is how to insert unique value for every row inserted. I tried using “generated always as”...
12
by: Ivan Popov | last post by:
I need to generate a unique serial number for each field in the table. The serial number shall consist of two letters and six numbers, for example AA123456. Someone can suggest how to do it in MS...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.