.NET How can I force a datarow to write (if it was not changed)
Posted on 2013-10-27
I have a large VB.net application to a database shared amongst several users. The code uses datatables to hold items while the user reviews data or, sometimes, makes changes.
If 2 users make changes to the same datarow, a "Concurrency violation" occurs which I catch and then display an error to the user.
My Problem: there is a "Save" button on the form. If the user clicks this button, the data will be saved and potentially cause the Concurrency violation above if there is a conflict. BUT "Save" uses a data adapter.update() function. If the user has not made any changes, .Update will do nothing and even though some other user might have made changes, since .Update won't write this user's unchanged data, we never get the concurrency exception. I would like "Save" to force an update. Using datarow.SetModified() does NOT force the write if the datarow has actually not been changed.
How can I force .update to write the unchanged row?