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

Error on Insert Record

Hello,

I am creating a table has follows:

create table dbo.Tags
(
TagID uniqueidentifier not null
default NewID()
constraint PK_Tag primary key clustered,
TagText nvarchar(100) not null
)

I am using a LinqDataSource and a ListView to create records in this
table. I am able to delete and update records but when I insert a
record I get the error:

Violation of PRIMARY KEY constraint 'PK_Tag'. Cannot insert duplicate
key in object 'dbo.Tags'. The statement has been terminated.

In fact I am able to insert ONE record and its ID becomes:
00000000-0000-0000-0000-000000000000

So when I insert a second one, I suppose, the ID is 000... again and
this is why I get the error ...

What am I doing wrong?

Thanks,
Miguel
Feb 6 '08 #1
2 1271
Hi Miguel,

Please refer to the link below to insert the values in the Tags table. You
will have to specify the firsl column value as newid(), which will create a
new value for the TagID field.

http://technet.microsoft.com/en-us/l.../ms190348.aspx

Regards,
Manish
www.ComponentOne.com
"shapper" wrote:
Hello,

I am creating a table has follows:

create table dbo.Tags
(
TagID uniqueidentifier not null
default NewID()
constraint PK_Tag primary key clustered,
TagText nvarchar(100) not null
)

I am using a LinqDataSource and a ListView to create records in this
table. I am able to delete and update records but when I insert a
record I get the error:

Violation of PRIMARY KEY constraint 'PK_Tag'. Cannot insert duplicate
key in object 'dbo.Tags'. The statement has been terminated.

In fact I am able to insert ONE record and its ID becomes:
00000000-0000-0000-0000-000000000000

So when I insert a second one, I suppose, the ID is 000... again and
this is why I get the error ...

What am I doing wrong?

Thanks,
Miguel
Feb 6 '08 #2
On Feb 6, 9:26 am, Manish <Man...@discussions.microsoft.comwrote:
Hi Miguel,

Please refer to the link below to insert the values in the Tags table. You
will have to specify the firsl column value as newid(), which will create a
new value for the TagID field.

http://technet.microsoft.com/en-us/l.../ms190348.aspx

Regards,
Manishwww.ComponentOne.com

"shapper" wrote:
Hello,
I am creating a table has follows:
create table dbo.Tags
(
TagID uniqueidentifier not null
default NewID()
constraint PK_Tag primary key clustered,
TagText nvarchar(100) not null
)
I am using a LinqDataSource and a ListView to create records in this
table. I am able to delete and update records but when I insert a
record I get the error:
Violation of PRIMARY KEY constraint 'PK_Tag'. Cannot insert duplicate
key in object 'dbo.Tags'. The statement has been terminated.
In fact I am able to insert ONE record and its ID becomes:
00000000-0000-0000-0000-000000000000
So when I insert a second one, I suppose, the ID is 000... again and
this is why I get the error ...
What am I doing wrong?
Thanks,
Miguel
But please look at the code I posted:

TagID uniqueidentifier not null
default NewID()

In fact this works fine with an SQL Query.
But when I am using the ListView and LinqDataSource this does not
work.

Any idea?

Thanks,
Miguel
Feb 6 '08 #3

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

Similar topics

6
by: Matthew Louden | last post by:
The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application deletes a record, such as sqlStmt ="delete from...
0
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
9
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
0
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include...
4
by: Tonio Tanzi | last post by:
I have the following problem in a Win 2000 Server + SQL Server 2000 environment and I hope somewhat can help me to resolve it (after many days of useless attempts I am desperate). In my database...
2
by: Gunners | last post by:
#include<iostream.h> #include<conio.h> #include<stdio.h> #include<stdlib.h> struct st_base { char name; int roll_no; int s1,s2,s3,s4,mks; float percentage;
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:
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.