G
Guest
Hi, I cannot understand why the following code gives me an
"OutOfRangeException" at deletion of the last datarow (i=9) to delete from
the datatable DT. Number of rows are 10 (max=10):
Dim max As Integer DT.Rows.Count
'************ USE ROW INFORMATION ****************
Dim message As String = ""
Dim i As Integer
Dim dr As DataRow
For i = 0 To (max - 1)
dr = DT.Rows(i) : message = message + CStr(dr(0)) + " " + CStr(dr(1))
+ ControlChars.CrLf
Next
'**************** DELETE ROWS *****************
For i = (max - 1) To 0 Step -1
dr = DT.Rows(i)
DT.Rows.Remove(dr)
Next
'********************************************
Have tried with Delete() & AcceptChanges, but with same error message.
"OutOfRangeException" at deletion of the last datarow (i=9) to delete from
the datatable DT. Number of rows are 10 (max=10):
Dim max As Integer DT.Rows.Count
'************ USE ROW INFORMATION ****************
Dim message As String = ""
Dim i As Integer
Dim dr As DataRow
For i = 0 To (max - 1)
dr = DT.Rows(i) : message = message + CStr(dr(0)) + " " + CStr(dr(1))
+ ControlChars.CrLf
Next
'**************** DELETE ROWS *****************
For i = (max - 1) To 0 Step -1
dr = DT.Rows(i)
DT.Rows.Remove(dr)
Next
'********************************************
Have tried with Delete() & AcceptChanges, but with same error message.