inserting row in dataset PB

  • Thread starter Thread starter fh
  • Start date Start date
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
 
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.
 
Back
Top