You should use some column to indentify the last updated date time. Takin your case, applying my approach:
In the database I have one row which user A and user B both are tryin to update.
What I suggest is:
To update a record you need to select the same, while selcting provide the last updated datetime as well, suppose that was 080820081112. So, user A and user B both have selected the same record and has same last updated datetime value i.e. 080820081112. Now, when user A updates the records, obviously the last updated datetime value would be changed, supposse it bacame 080820081116, now when user B tries to update the same, since the value of last updated datetime does not match with the current one in the database, throw a diffferent message.
Thats it!
Thanks,
Atanu