Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Error on Insert Record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 06 Feb 2008 03:01 GMT
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
Manish - 06 Feb 2008 09:26 GMT
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/library/ms190348.aspx

Regards,
Manish
www.ComponentOne.com

> Hello,
>
[quoted text clipped - 25 lines]
> Thanks,
> Miguel
shapper - 06 Feb 2008 14:00 GMT
> Hi Miguel,
>
[quoted text clipped - 36 lines]
> > 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.