I'm having an issue when i'm trying to save the modification I make in my dbase. I'm using a save button, the first save work fine but if I modify my data and try to save again I get this message: concurrency violation the updatecommand affected 0 of the expected 1 records. I get this message at the tableadapter.udapte line. I'm using visual basic express 2010. Here's my codes for my save button:
This is simply because DataSet (or ADO.Net rather) uses Optimistic Concurrency by default.
This means that when updating, the whole row (rather than the changed column only) is used for comparison with the data in the database.
This then means that if you are trying to update a row that no longer exists in the database, the update from the DataAdapter the update will fail with the exception above.
Typical scenarios when this may happen is that you get your data into the disconnected DataSet, you do some work on it and then try the update.
However, between you selecting the data into the client and sending the update, another user is deleting this row from his application.
Or it can be that you are deleting the data from somewhere else in your application.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz' save a blobFileStreamDataTable To Text File