Error inserting into an identity column

M

Michael Jackson

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
 
W

William \(Bill\) Vaughn

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.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top