473,473 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Duplicate GUID problem

I know that this should be impossible, yet it is happening...

I have some c# code that uses a method scoped variable of type Guid. The
code assigns Guid.NewGuid() to the variable. This value is then used as a
primary key in a database table.

I have seen two occasions over the last 6 months where after a certain point
in time the same Guid is always generated by the code.

I have verified that there is nothing static, the code is actually very
simple.

The only interesting fact here is that the code is running under IIS via a
web service. Doing an IISRESET makes the problem go away.

Does anyone have any insight as to how this problem could be??

TIA
Rob
Nov 22 '05 #1
3 4793
On Tue, 15 Jun 2004 12:31:10 -0400, Robert Chapman wrote:
I have some c# code that uses a method scoped variable of type Guid. The
code assigns Guid.NewGuid() to the variable. This value is then used as a
primary key in a database table.

TIA
Rob


Don't use GUIDs for primary keys. That's why they invented identity
columns.

Mark
Nov 22 '05 #2
Identity columns are no good for:
- replication scenarios
- foreign key relationships in disconnected datasets

Check out any modern product, such as MS CRM, GUIDS are the way to go.

"Mark" <me@here.there> wrote in message
news:4f****************************@40tude.net...
On Tue, 15 Jun 2004 12:31:10 -0400, Robert Chapman wrote:
I have some c# code that uses a method scoped variable of type Guid. The code assigns Guid.NewGuid() to the variable. This value is then used as a primary key in a database table.

TIA
Rob


Don't use GUIDs for primary keys. That's why they invented identity
columns.

Mark

Nov 22 '05 #3
Other way around, Mark,

I ONLY use GUIDs as the primary key, if I can help it. I still sometimes
use identity columns, but only as a way to assign a "human friendly" code to
a record whose primary key is still a GUID.

That way, I get much better performance and scalability.
Replication works a darn-site better too.

--- Nick Malik

"Mark" <me@here.there> wrote in message
news:4f****************************@40tude.net...
On Tue, 15 Jun 2004 12:31:10 -0400, Robert Chapman wrote:
I have some c# code that uses a method scoped variable of type Guid. The code assigns Guid.NewGuid() to the variable. This value is then used as a primary key in a database table.

TIA
Rob


Don't use GUIDs for primary keys. That's why they invented identity
columns.

Mark

Nov 22 '05 #4

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

Similar topics

3
by: Robert Chapman | last post by:
I know that this should be impossible, yet it is happening... I have some c# code that uses a method scoped variable of type Guid. The code assigns Guid.NewGuid() to the variable. This value is...
2
by: Jiho Han | last post by:
I generated a class from a schema. One of the fields are typed as System.Guid. Perfect. The only problem is when this class serializes, the guid field serializes as...
16
by: Jay Douglas | last post by:
Does anybody know the odds of generating a duplicate guid? -- Jay Douglas http://jaydouglas.com
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
4
by: Doug Bell | last post by:
Hi, I have been having problems getting a Project to reference another project in as VS Solution. I believe that the reason the reference is not accepted is because another project that is...
10
by: Charles Hunt | last post by:
Hi, When running this code in VB2003 Sub guidtest() Dim gstring As String Dim gid As Guid
1
by: Jeff | last post by:
ASP.NET 2.0 This problem occur using the basic version of SQL Server 2005 which get installed when installing Visual Studio 2005! I have inserted a record in the Test table. But when I try to...
3
by: sloan | last post by:
I know a Dictionary < TKey, TValue does not allow duplicate keys. System.Collections.Generic.Dictionary<Guid, Guidtest = new System.Collections.Generic.Dictionary<Guid, Guid>(); //duplicate key...
4
by: Marc | last post by:
Hi, I don't get it I cannot get this to work, can somebody give me a hint Table1 contains a field Id which is a GUID as primary key and DATA a string, I want to insert a new row but it does not...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.