I have a class containing public shared variables to hold the originally
read fields from the Team Table. (2 fields)
I use the sql string listed below to update the description field. It does
update the database when no concurrency problem occurs. If a concurrency
does occur, the update does not occur because the Where Clause prevents it,
but no exception is thrown. I have the update in a try / catch block but no
exceptions are caught.
I'm not sure why. It would seem that the numbers of rows affected by the
update would be 0.
Dim sqlUpdate As String = "Update TeamTable " & _
"Set TeamTable.Description = '" & strDescription & "' " & _
"Where TeamTable.ID = '" & cOrigTeam.strTeamID & "' And " & _
"TeamTable.Description = '" & cOrigTeam.strTeamDescription & "' "
"CaffieneRush" <Ca**********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
If your sql update statement was written correctly using either the
verson number or saving-all-values approach then the
adpTeam.UpdateCommand.ExecuteNonQuery()
statement should raise a DBConcurrencyException when the number of rows
affected by the update is zero which is generally a concurrency
violation.
In this way, you don't have to explicitly raise a concurrency
exception.
Andy
William E Voorhees wrote:
>I'm updating an Access database in a windows multi-user environment.
I'm using disconnected data
I read data from an Access Data table to a data object
I update the data object from a windows form
I save the data from the data object to the Access Data table using a
data
adapter as follows:
adpTeam.UpdateCommand = New OleDbCommand(sqlUpdate)
adpTeam.UpdateCommand.Connection = aConnection
adpTeam.UpdateCommand.ExecuteNonQuery()
Since I'm not using datasets, how do I use optimistic concurrency and
throw
a concurrency exception if one occurs?