T
Terry Burns
This code takes the Person index drom the datagrid dgPeople and uses it to
delete all the records from the dgEvents grid and underlying records. It
works but i do get that concurrency message
Case "Delete"
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("Original_PersonIndex",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))
Dim r As DataRow
PersonIndex = CType(dgPeople.Item(dgPeople.CurrentRowIndex, 0), Int32)
For Each r In tableEvents.Rows
If PersonIndex = CType(r.Item(0), Int32) Then
r.Delete()
End If
Next
daEvents.DeleteCommand = DeleteCmd
daEvents.Update(tableEvents)
Catch ex As OleDbException
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
delete all the records from the dgEvents grid and underlying records. It
works but i do get that concurrency message
Case "Delete"
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("Original_PersonIndex",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"PersonIndex", System.Data.DataRowVersion.Original, Nothing))
Dim r As DataRow
PersonIndex = CType(dgPeople.Item(dgPeople.CurrentRowIndex, 0), Int32)
For Each r In tableEvents.Rows
If PersonIndex = CType(r.Item(0), Int32) Then
r.Delete()
End If
Next
daEvents.DeleteCommand = DeleteCmd
daEvents.Update(tableEvents)
Catch ex As OleDbException
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try