What happens when you delete a DataRow ?

  • Thread starter Thread starter Terry Burns
  • Start date Start date
T

Terry Burns

I know that the state is changed to deleted, but what else happens ?, does
the table make a new version of itself each time or the row ?

The reason i'm asking is because I'm have a tough time understanding how
making changes to more than one row ( but not more than one change per row )
and then trying to update the dataadapter can cause a concurrency error.
There are no other users involved

any assistance is appreciated in understanding this . . .


Regards - Terry
 
A concurrency error just really means, that the adapter expect X rows to
successfully be updated/inserted/deleted - but that did not happen. This
typically happens because the conditions in the WHERE clause of the
generated queries are not met. It is assumed that this is a concurrency
issue (i.e. another user already changed this row, that's why the WHERE
conditions are not met).

Show us some code...
 
try

'open connection

con.Open()

'Setup the Delete Command for events for this person

DeleteCmd.CommandText = "DELETE FROM Events " 'WHERE PersonIndex = ?"

DeleteCmd.Connection = con

DeleteCmd.CommandType = CommandType.Text

DeleteCmd.Parameters.Add(New System.Data.OleDb.OleDbParameter("PersonIndex",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))

daEvents.DeleteCommand = DeleteCmd

Dim r As DataRow

PersonIndex = CType(dgPeople.Item(dgPeople.CurrentRowIndex, 0), Int32)

Dim rc As Int32

Dim drc As DataRowCollection = tableEvents.Rows

For rc = drc.Count - 1 To 0 Step -1

drc(rc).Delete()

Next

daEvents.Update(tableEvents)

Catch ex As System.Data.DBConcurrencyException

MessageBox.Show(ex.Message)

Finally

If con.State = ConnectionState.Open Then

con.Close()

End If

DeletingRows = False

End Try
 
Back
Top