Find() With multiple primary keys
I am having this problem with a delete function on a table with 3 Primary Keys. After spending some time on the internet, I found a few answers but I am still unable to get it to work. It is not throwing any errors but the row is getting no value with the following code:
If (Not (keys Is Nothing)) Then row = DataSet31.Tables(Table).Rows.Find(keys)
Here is the entire code snipit:
Private Sub PenXrefGrid_DeleteRowBatch(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles PenXrefGrid.DeleteRowBatch
'Dim table As DataTable
Dim table As String
table = "tbl_Vet_Pen_Xref"
Dim row As DataRow
Dim keys(2) As Object
'table = DataSet31.Tables(e.Row.Band.BaseTableName)
keys(0) = e.Row.DataKey(0)
keys(1) = e.Row.DataKey(1)
keys(2) = e.Row.DataKey(2)
'Try to find the row that needs to be deleted.
If (Not (keys Is Nothing)) Then row = DataSet31.Tables(table).Rows.Find(keys)
If (Not (row Is Nothing)) Then
Try
row.Delete()
Catch
DataSet31.RejectChanges()
End Try
End If
End Sub
Any help?
|