Unique Identifier

B

ba.hons

Hello all,

Was wondering if anyone could provide some info on what could be a
possible solution to a problem am having.

I have to generate a Unique Identifier in C# which I will use to
assign to a user, i dont really need the Unique Identifier's to be
sequential so i was considering using system.time.hour +
system.time.minute. + system.time.second, but am worried about
daylight savings and also people altering the time on the host PC.

I dont really want to use a database with just one table and one
field, and i would prefer to not use a file which just saves the value
and increments by one each time i want a new Unique Identifier.

Does anyone know of a way i could get a Unique Identifier??


thanks,


Adam
 
B

ba.hons

My Apologies,

I should have said, i need the unique ID to be numeric as it will be
stored in a database at some stage, and i have no control on what the
ID field in the DB can be.

Thanks

Adam
 
P

Peter Bradley

Unique in what domain?

If you simply want a unique uid, what's wrong with an ID field?


Peter
 
O

Otis Mukinfus

Hello all,

Was wondering if anyone could provide some info on what could be a
possible solution to a problem am having.

I have to generate a Unique Identifier in C# which I will use to
assign to a user, i dont really need the Unique Identifier's to be
sequential so i was considering using system.time.hour +
system.time.minute. + system.time.second, but am worried about
daylight savings and also people altering the time on the host PC.

I dont really want to use a database with just one table and one
field, and i would prefer to not use a file which just saves the value
and increments by one each time i want a new Unique Identifier.

Does anyone know of a way i could get a Unique Identifier??


thanks,


Adam

After reading all the other suggestions given you and your responses it seems
you've rejected all the common methods of assigning unique identifiers.

Your idea that you can use the hour minute and second to do that is flawed
because in the database world generation of data can occur simultaneously. Using
the time generated method would indeed assure that you would end up with
duplicate identifiers because of the lack of resolution.

I once worked for a small company whose HR department dictated that employees be
issued employee IDs that were the last four digits of their social security
number. When I told them it wouldn't work they laughed. Two months later after
hiring an new employee we hit the first duplicate. They didn't think it was
funny after that.

Take the advice given you. You'll be glad you did.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top