473,386 Members | 1,694 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,386 software developers and data experts.

Creating a GUID???

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.

Nov 16 '05 #1
7 1694
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.

Nov 16 '05 #2
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" <st**********@lineone.net> a écrit dans le message de news:
u5**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 16 '05 #3
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.

Nov 16 '05 #4
Thanks everyone, Guid.NewGuid() works a treat.

"Steve" <st**********@lineone.net> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 16 '05 #5
What db are you using?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"Steve" <st**********@lineone.net> wrote in message
news:e%****************@TK2MSFTNGP11.phx.gbl...
Thanks everyone, Guid.NewGuid() works a treat.

"Steve" <st**********@lineone.net> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
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.


Nov 16 '05 #6
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" <co*****************@nospam.com> wrote in message
news:ue**************@TK2MSFTNGP14.phx.gbl...
What db are you using?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"Steve" <st**********@lineone.net> wrote in message
news:e%****************@TK2MSFTNGP11.phx.gbl...
Thanks everyone, Guid.NewGuid() works a treat.

"Steve" <st**********@lineone.net> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
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.



Nov 16 '05 #7
Okay then it's all cool.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"Steve" <st**********@lineone.net> wrote in message
news:OS**************@TK2MSFTNGP15.phx.gbl...
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" <co*****************@nospam.com> wrote in message
news:ue**************@TK2MSFTNGP14.phx.gbl...
What db are you using?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"Steve" <st**********@lineone.net> wrote in message
news:e%****************@TK2MSFTNGP11.phx.gbl...
> Thanks everyone, Guid.NewGuid() works a treat.
>
> "Steve" <st**********@lineone.net> wrote in message
> news:u5**************@TK2MSFTNGP09.phx.gbl...
>> 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.
>>
>>
>>
>
>



Nov 16 '05 #8

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

Similar topics

0
by: Richard Blewett [DevelopMentor] | last post by:
Use the static NewGuid method of the System.Guid class: Guid g = Guid.NewGuid(); Regards Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
4
by: Ivar | last post by:
Hi, How to generate GUID("f741d0ce-351c-4c8d-9625-d23765ca7f45") values in postgre ? ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the...
2
by: Guy | last post by:
I want to create a new value type for hiding the creation of Guid's that can be used in my business classes. I suppose I have to achieve this by creating a struct (ID) The problem is I'm...
16
by: Asaf | last post by:
I am trying to create and use a COM object with C#.NET 2005. The assembly is set to "Register for COM interop" but when I am trying to call it from VB on Word 2003 I am getting this error: ...
11
by: rayala | last post by:
Hi all, I am having very weird problem in my Outlook I am running my web application from with in Outlook.I found a strange problem that it is creating different sessionId if i open a new...
2
by: doug | last post by:
G'day all, I'm a newbie to .net (7 years or so as a vb/asp programmer) and I'm trying to create a GUID using the GUID type in vb.net Here's the code I'm using to create it : Public Function...
4
by: tom | last post by:
I called regasm.exe /tlb CameraManagement.dll and I got CameraManagement.tlb When I look inside with OleView.exe or create C++ header I see something like that: struct...
1
by: kret | last post by:
Hi, this is my first post so first of all I would like to say hello :) Now getting to my problem. In my job I have to create an ActiveX control in .NET 1.1 that can be lunched from IE....
4
by: kageyone | last post by:
I have an access database with a table with two fields. They are 1. a GUID field and 2. a comma delimited set of values. I want to take this table and for each row I want to do the following: ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.