J
Jeff
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 insert a
second record I get this error:
{"Violation of PRIMARY KEY constraint 'PK_Test'. Cannot insert duplicate key
in object 'dbo.Test'.
The primary key value in the only record in the table Test has this value
00000000-0000-0000-0000-000000000000
Here you see how the Id value is calculated in my problem code. I thought
"new System.Guid()" should use a combination of datetime and the MAC address
on network card to generate a truly unique value. But it looks I'm wrong
about that.
TestInfo test = new TestInfo(new System.Guid(), "test value");
This is the definition of this Test table
create table Test (
Id uniqueidentifier not null,
Value nvarchar(2000),
CONSTRAINT PK_Test PRIMARY KEY (Id)
)
"new System.Guid()" don't generate a unique value, what should I do to make
it generate a unique value???
Best Regards!
Jeff
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 insert a
second record I get this error:
{"Violation of PRIMARY KEY constraint 'PK_Test'. Cannot insert duplicate key
in object 'dbo.Test'.
The primary key value in the only record in the table Test has this value
00000000-0000-0000-0000-000000000000
Here you see how the Id value is calculated in my problem code. I thought
"new System.Guid()" should use a combination of datetime and the MAC address
on network card to generate a truly unique value. But it looks I'm wrong
about that.
TestInfo test = new TestInfo(new System.Guid(), "test value");
This is the definition of this Test table
create table Test (
Id uniqueidentifier not null,
Value nvarchar(2000),
CONSTRAINT PK_Test PRIMARY KEY (Id)
)
"new System.Guid()" don't generate a unique value, what should I do to make
it generate a unique value???
Best Regards!
Jeff