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

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 4787
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
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.