RE: Resolving Conflicts

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



hi, thanks for the replay

so suppose i want the last update to win without bothering the user i think
as start it will simplify my application how can that be done ? does it also
require coding ?
how the code you posted will change ?

but still i need to implement code for deleted records ?

""Hongye Sun [MSFT]"" wrote:

Hi Ammar,

Thanks for your reply.

When conflict happens, it is up to you to add code to handle the errors
based upon your own business requirements. ADO.NET provides a
DBConcurrencyException object that returns the row that violates the
concurrency rules. For more information, see How to: Handle Concurrency
Errors (http://msdn.microsoft.com/en-us/library/y8fyz6xy.aspx).

Here is an example code to handle concurrency error:

Try
CustomersTableAdapter.Update(NorthwindDataSet)

Catch ex As DBConcurrencyException

Dim customErrorMessage As String
customErrorMessage = "Concurrency violation" & vbCrLf
customErrorMessage += CType(ex.Row.Item(0), String)
MessageBox.Show(customErrorMessage)

' Add business logic code to resolve the concurrency violation...

End Try

For your second question, UPDATE operation requires the record you are
updating is existing in the database. So in the senario you provided, the
operation will raise a DBConcurrencyException as mentioned above.

For ADD and DELETE operations:
Adding new records (the INSERT command) only requires the current values
since no original record exists and removing records (the DELETE command)
only requires the original values in order to locate the record to delete,
which is similar to UPDATE.

Please let me know if you need anything else unclear.

Sincerely,
Hongye Sun (hongyes@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

This posting is provided "AS IS" with no warranties, and confers no rights.




.



Relevant Pages

  • RE: Resolving Conflicts
    ... based upon your own business requirements. ... DBConcurrencyException object that returns the row that violates the ... see How to: Handle Concurrency ... Dim customErrorMessage As String ...
    (microsoft.public.vsnet.general)
  • about concurrency (again)
    ... I have been reading the recent thread about concurrency, ... def disable_safe_mode: ... # "instantiate" the manager in the main thread ... the lock could be a file lock or a transactional lock. ...
    (comp.lang.functional)
  • RE: Concurrency issue
    ... Microsoft MSDN Online Support Lead ... You can send feedback directly to my manager at: ... Subject: Concurrency issue ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • RE: LINQ to SQL and Merge Replication
    ... For concurrency issues, yes, I agree with your ... DBA. ... Microsoft Online Community Support ... Please feel free to let my manager ...
    (microsoft.public.sqlserver.replication)
  • in memory db of 200 GB
    ... (using a persistence layer as hibernate in order to manager ... concurrency and transactions). ...
    (comp.lang.java.databases)