Does anyone have any ideas about what is wrong?
You need to use the do/while or do/until loop instead and use an integer value to loop through all the items. Because the for loops store the top number at the beginning of the enumartion, deleting a row should not be allow.
I haven't tried this but the general idea should be correct.
Dim iOutRow As Integer = 0
Dim iNrow As Integer = 0
Dim dtTemp As New DataTable()
Do While Not iOutRow = dtTemp.Rows.Count - 1
iNrow = 0
Do While Not iNrow = dtTemp.Rows.Count - 1
If dtTemp.Rows(iNrow) Is dtTemp.Rows(iOutRow) AndAlso Not iNrow = iOutRow Then
dtTemp.Rows.RemoveAt(iNrow)
iOutRow -= 1
Continue Do
End If
iNrow += 1
Loop
iOutRow += 1
Loop
Edit: Looking back onto my code, it'd be better if you had a field value to verify rather than the rows being identical as there is an issue of deleting the first row. Hope this gets you on your way though; let me know what you come up with.