PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Error inserting into an identity column

Reply

Error inserting into an identity column

 
Thread Tools Rate Thread
Old 14-05-2005, 12:56 AM   #1
Michael Jackson
Guest
 
Posts: n/a
Default Error inserting into an identity column


My .NET 2003 program uses a dataset bound to a form to insert records into a
SQL Server 2000 table. The key column is IDENTITY(1,1). When I perform a
Dataset.Update, I get an error stating that Value '1' is already in the
table. Turns out that ONLY the first row (ID of 1) of the dataset is
inserted into the table. This happens if I have 2 records in the dataset, or
dozens.

Any ideas?

Michael


  Reply With Quote
Old 14-05-2005, 02:42 AM   #2
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: Error inserting into an identity column

How are you creating the action Commands? You should not be changing the
identity value in an UPDATE statement or anywhere else. This value is
generated by the server or database engine so you don't have to provide
these values at all.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Michael Jackson" <michaeldjackson@cox.net> wrote in message
news:g9bhe.35082$fx3.20924@okepread02...
> My .NET 2003 program uses a dataset bound to a form to insert records into
> a SQL Server 2000 table. The key column is IDENTITY(1,1). When I perform a
> Dataset.Update, I get an error stating that Value '1' is already in the
> table. Turns out that ONLY the first row (ID of 1) of the dataset is
> inserted into the table. This happens if I have 2 records in the dataset,
> or dozens.
>
> Any ideas?
>
> Michael
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off