PC Review


Reply
Thread Tools Rate Thread

Creating a GUID???

 
 
Steve
Guest
Posts: n/a
 
      2nd Jan 2005
I need to generate a unique number/string of some description and thought a
guid would be ideal.
Any ideas on how to generate a guid?

I'm not using SQL server so SELECT NEWID() is out but something similar in
code would be great.

I've looked at the System.Guid class but can't figure how to have it
generate a fresh GUID.

Thanks for any pointers.



 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      2nd Jan 2005
You can use the static NewGuid method on the Guid struct.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

> I need to generate a unique number/string of some description and
> thought a
> guid would be ideal.
> Any ideas on how to generate a guid?
> I'm not using SQL server so SELECT NEWID() is out but something
> similar in code would be great.
>
> I've looked at the System.Guid class but can't figure how to have it
> generate a fresh GUID.
>
> Thanks for any pointers.
>



 
Reply With Quote
 
José Joye
Guest
Posts: n/a
 
      2nd Jan 2005
I guess you have to call the static method Guid.NewGuid(). This will return
you a new instance. Then, if you need to extract the generated value, call
either the ToString() or ToByteArray() method.

- José

"Steve" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
>I need to generate a unique number/string of some description and thought a
> guid would be ideal.
> Any ideas on how to generate a guid?
>
> I'm not using SQL server so SELECT NEWID() is out but something similar in
> code would be great.
>
> I've looked at the System.Guid class but can't figure how to have it
> generate a fresh GUID.
>
> Thanks for any pointers.
>
>
>



 
Reply With Quote
 
=?Utf-8?B?cmFtb25yZWQ=?=
Guest
Posts: n/a
 
      2nd Jan 2005
Okay Steve, I am a newbie but I think this might help.

I am taking this from some code I wrote that inserts a guid into a database,
but doesn't use a SELECT satement to create it.

I am going to include the code before, to give it context. Here goes:
string sql = @"
INSERT INTO [TableName]
(UserID, Name)
VALUES
('{0}','{1}')";

values.Add(Guid.NewGuid().ToString()); //this is code you want
value.Add(txtName.Text); //this referes to a text box on a webform

please let me know if that helps, apologies if I only confused the issue.

best

"Steve" wrote:

> I need to generate a unique number/string of some description and thought a
> guid would be ideal.
> Any ideas on how to generate a guid?
>
> I'm not using SQL server so SELECT NEWID() is out but something similar in
> code would be great.
>
> I've looked at the System.Guid class but can't figure how to have it
> generate a fresh GUID.
>
> Thanks for any pointers.
>
>
>
>

 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      2nd Jan 2005
Thanks everyone, Guid.NewGuid() works a treat.

"Steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I need to generate a unique number/string of some description and thought

a
> guid would be ideal.
> Any ideas on how to generate a guid?
>
> I'm not using SQL server so SELECT NEWID() is out but something similar in
> code would be great.
>
> I've looked at the System.Guid class but can't figure how to have it
> generate a fresh GUID.
>
> Thanks for any pointers.
>
>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      2nd Jan 2005
What db are you using?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


"Steve" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> Thanks everyone, Guid.NewGuid() works a treat.
>
> "Steve" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I need to generate a unique number/string of some description and thought

> a
>> guid would be ideal.
>> Any ideas on how to generate a guid?
>>
>> I'm not using SQL server so SELECT NEWID() is out but something similar
>> in
>> code would be great.
>>
>> I've looked at the System.Guid class but can't figure how to have it
>> generate a fresh GUID.
>>
>> Thanks for any pointers.
>>
>>
>>

>
>



 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      3rd Jan 2005
I'm not using any, Its a file based app which creates template files that
needed some unique ID mainly for internal purposes.

"Sahil Malik" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What db are you using?
>
> - Sahil Malik
> http://dotnetjunkies.com/weblog/sahilmalik
>
>
> "Steve" <(E-Mail Removed)> wrote in message
> news:e%(E-Mail Removed)...
> > Thanks everyone, Guid.NewGuid() works a treat.
> >
> > "Steve" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> I need to generate a unique number/string of some description and

thought
> > a
> >> guid would be ideal.
> >> Any ideas on how to generate a guid?
> >>
> >> I'm not using SQL server so SELECT NEWID() is out but something similar
> >> in
> >> code would be great.
> >>
> >> I've looked at the System.Guid class but can't figure how to have it
> >> generate a fresh GUID.
> >>
> >> Thanks for any pointers.
> >>
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      3rd Jan 2005
Okay then it's all cool.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


"Steve" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm not using any, Its a file based app which creates template files that
> needed some unique ID mainly for internal purposes.
>
> "Sahil Malik" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> What db are you using?
>>
>> - Sahil Malik
>> http://dotnetjunkies.com/weblog/sahilmalik
>>
>>
>> "Steve" <(E-Mail Removed)> wrote in message
>> news:e%(E-Mail Removed)...
>> > Thanks everyone, Guid.NewGuid() works a treat.
>> >
>> > "Steve" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >> I need to generate a unique number/string of some description and

> thought
>> > a
>> >> guid would be ideal.
>> >> Any ideas on how to generate a guid?
>> >>
>> >> I'm not using SQL server so SELECT NEWID() is out but something
>> >> similar
>> >> in
>> >> code would be great.
>> >>
>> >> I've looked at the System.Guid class but can't figure how to have it
>> >> generate a fresh GUID.
>> >>
>> >> Thanks for any pointers.
>> >>
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
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
Re: Creating a GUID jamie Microsoft C# .NET 0 14th Sep 2004 05:49 PM
Re: Creating a GUID Tom Shelton Microsoft C# .NET 0 14th Sep 2004 05:48 PM
Creating a GUID Richard Blewett [DevelopMentor] Microsoft C# .NET 0 14th Sep 2004 05:46 PM
Re: Creating a GUID Shiva Microsoft C# .NET 0 14th Sep 2004 05:45 PM
Re: Creating a GUID Scott Allen Microsoft C# .NET 0 14th Sep 2004 05:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:52 PM.