PC Review


Reply
Thread Tools Rate Thread

Unique Identifier

 
 
ba.hons
Guest
Posts: n/a
 
      31st Jan 2007
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

 
Reply With Quote
 
 
 
 
Galcho
Guest
Posts: n/a
 
      31st Jan 2007
Consider using Guid structure (http://msdn2.microsoft.com/en-us/
library/system.guid.aspx)

this would be something like:
user.Id = new Guid.NewGuid();

Hope this helps,
Galin Iliev [MCSD.NET, MCPD]
www.galcho.com

 
Reply With Quote
 
 
 
 
ba.hons
Guest
Posts: n/a
 
      31st Jan 2007
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

 
Reply With Quote
 
Peter Bradley
Guest
Posts: n/a
 
      31st Jan 2007
Unique in what domain?

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


Peter

"ba.hons" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Otis Mukinfus
Guest
Posts: n/a
 
      31st Jan 2007
On 31 Jan 2007 02:33:19 -0800, "ba.hons" <(E-Mail Removed)> wrote:

>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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD Error: "Expecting '.', identifier or quoted identifier withmultiple tables. S_K Microsoft ASP .NET 0 6th Aug 2008 10:22 PM
Assigning unique identifier to unique authors =?Utf-8?B?Ymx1ZXNreQ==?= Microsoft Access Queries 5 3rd Aug 2007 09:12 PM
identifier not found error, undeclared identifier aarthi28@gmail.com Windows XP WMI 3 26th Feb 2007 03:11 AM
identifier not found error, undeclared identifier aarthi28@gmail.com Microsoft VC .NET 3 26th Feb 2007 03:11 AM
Windows OS Unique Identifier Cap Windows XP General 1 13th May 2004 07:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:31 PM.