inserting row in dataset PB

F

fh

Hello,
I use a typed dataset in one table I have

this.columnID.AutoIncrement = true;

I thought that would let the dataset dealing with the generation of
primary key.

but when I insert a new datarow that way:
DataRow drDowntimeSup = _dsDowntime.Tables["PPE_DOWNTIME"].NewRow();
drDowntimeSup.BeginEdit();
drDowntimeSup.ItemArray= drCurentLine.ItemArray;
//drCurentLine is an existing line
.......... I changed some columns, not the "ID" column.

drDowntimeSup.EndEdit();
_dsDowntime.Tables["PPE_DOWNTIME"].Rows.Add(drDowntimeSup);

I receive the following:

->Column 'ID' is constrained to be unique. Value '33771' is already present.

Am I missing something?

thank you
Franck
 
W

W.G. Ryan MVP

Set the seed to -1 so that it generates negative numbers. THat's the only
feasible way to ensure that your clients don't step on each other with new
values. There are other ways to get there, but using negative numbers, and
letting the db assign the values, is the only practical way I know of short
of writing a whole lot of code to work around it.
 

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