I am using this code to compare two datatables(myTable and Dtable) and when I find two rows with common data I delete the rows in my other datatable(dtable) so that dtable comes up with data that is not already in myTable. However the code is not doing that at all. what could be wrong with my code
An Example of what I am hoping for is as follows
Datatable1(Dtable) Datatable2(myTable) Final Datatable1(Dtable)
brian kelvin brian
kelvin richard
richard
For Each myRow As DataRow In myTable.Rows
'Dim filter As String = String.Format("RawMaterialCode='{0}'", myRow("RawMaterialCode"))
Dim filter As String = String.Format("RawMaterialCode='{0}'", myRow("RawMaterialCode"))
For Each dRow As DataRow In dTable.Select(filter)
myAddArray(myTable.Rows.Count) = myRow("RawMaterialCode")
'dRow.Delete()
Next
Next
dTable.AcceptChanges()
For Each key In myAddArray
Dim row = dTable.Rows.Find(key)
If row IsNot Nothing Then
'dTable.Rows.Remove(row)
row.Delete()
End If
Next