Inserting into an identity column fails

  • Thread starter Michael Jackson
  • Start date
M

Michael Jackson

Using .NET 2003, 1.1, SQL Server 2000 sp3a, I get the following error when
looping thru a listview and inserting the rows into a sql table with the ID
field as IDENTITY(1,1).

System.Data.ConstraintException: Column 'StoreID' is constrained to be
unique. Value '1' is already present.

However, if I change the column to IDENTITY(10000, 1), I get no error.

Any ideas what's wrong here?
 
M

Marvin Varela

You have to set these properties in the dataset field to the following
values:

AutoIncrementSeed = -1
AutoIncrementStep = -1
AutoIncrement = true

Hope that helps.
 

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