473,387 Members | 1,942 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,387 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 4489
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.