Inserted rows duplicated when merged Into original dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've ready every article and post on the autoincrement issue on this forum. I've spent countless hours on this and I'm no further than when I started. I'm just about to give up and switch to GUID's or generate my own ID's but I just want to make sure I'm not overlooking something simple.

I've read 'Managing the @@Identity Crisis' and I don't want that much complex code added for every master/detail relationship on my form. I've wasted 16 hours trying to get the negative autoincrement to work and its just not worth it for me.

If I'm using a SQL Server database with an AutoIncrement field - I add a new row and it selects what it thinks is the next ID number (or a negative ID) - meanwhile another user adds a new row, taking the id I have on my form - when I update the changed dataset and merge back into the original dataset, the row is now listed twice, once with the number the dataset generated, and once with the true identity value selected by SQL Server.

Before I jump ship, I just want to see if there is any simple way to avoid this.
 
Hi Denise,

Denise said:
I've ready every article and post on the autoincrement issue on this
forum. I've spent countless hours on this and I'm no further than when I
started. I'm just about to give up and switch to GUID's or generate my own
ID's but I just want to make sure I'm not overlooking something simple.
I've read 'Managing the @@Identity Crisis' and I don't want that much
complex code added for every master/detail relationship on my form. I've
wasted 16 hours trying to get the negative autoincrement to work and its
just not worth it for me.
If I'm using a SQL Server database with an AutoIncrement field - I add a
new row and it selects what it thinks is the next ID number (or a negative
ID) - meanwhile another user adds a new row, taking the id I have on my
form - when I update the changed dataset and merge back into the original
dataset, the row is now listed twice, once with the number the dataset
generated, and once with the true identity value selected by SQL Server.
Before I jump ship, I just want to see if there is any simple way to avoid
this.

Yes, you are right. The problem is within Merge method. It doesn't update
the rows.
I was going to write an article on this plus a class that solves the issue.
Here is what I do.
When I do GetChanges() I store every pair of new rows (original one and one
in getchanges() dataset).
After successful update and before merge, I go through all of my pairs and
manually update the original row (that with negative number) to the actual
value (from the other row).
Only after that I do merge.
It works.
 
Back
Top