I use a TableAdapter to update the database like this:
var changes = anpDatabase.AnpCollection.GetChanges();
anpCollectionTableAdapter.Update((AnpDatabase.AnpCollectionDataTable)changes);
anpDatabase.AnpCollection.Merge(changes);
anpDatabase.AnpCollection.AcceptChanges();
However this isn't enough to update the identity primary column... I tried putting changing the Insert Command of the adapter to the following:
INSERT INTO AnpCollection
(ParentCollectionId, StartDate, EndDate, Completed, IsPartial, Partitioned, IsAutomaticallyGenerated)
VALUES (@ParentCollectionId,@StartDate,@EndDate,@Completed,@IsPartial,@Partitioned,@IsAutomaticallyGenerated);
SELECT CollectionId, ParentCollectionId, StartDate, EndDate, Completed, IsPartial, Partitioned, IsAutomaticallyGenerated FROM AnpCollection WHERE (CollectionId = SCOPE_IDENTITY())
However, If I do this, instead of the column being updated, a new row appears with the correct identity value... That's not what I want... Can someone help me? Thanks in advance!
Leaving the
INSERT
statement with theSELECT
at the end, it seems like the right code here is:instead of: