update problems after adding rows

  • Thread starter Thread starter Bernie Yaeger
  • Start date Start date
B

Bernie Yaeger

I'm having difficulty I don't understand.

I add rows to a datatable and the update works fine. Then I try to edit
some of the columns and when I attempt to update, I get 'concurrency
violation'. So I added dataset.acceptchanges, but the problem continued.
However, if I open the sql table in question in another dataset/datatable, I
can make changes and the update works fine!

Any idea what's causing this behavior?

Tx for any help.

Bernie Yaeger
 
Check this: Prior to the Update call, check the state of your DataRow.
After the Update call, check the state of your DataRow. You should see
'Modified' and then 'UnChanged'. If not, there is an issue.
 
Bernie,

Is the database generating any values for the new row
(auto-increment, timestamp, defaults, etc.)? If so, attempting
to submit a subsequent change without having fetched these values
from the database after insert could explain the behavior.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
Tx Greg, David,

Thanks for your ideas. David, your absolutely correct - the add element has
an identity column and since I'm using a commandbuilder, I didn't see that.

Tx again to you both.

Bernie Yaeger
 
Bernie,

If you're working with an Access 2000 formatted database,
you can create your own updating logic to fetch the identity
value generated by the database in the DataAdapter's RowUpdated
event. See "Retrieving Identity or Autonumber Values" in the
.NET Framework SDK Documentation for more information. Once
you've fetched this database-generated information so the values
in your DataRow match those in the corresponding database row,
subsequent update attempts should succeed.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
Back
Top