alexlashford
Member
- Joined
- Jul 20, 2007
- Messages
- 7
- Programming Experience
- Beginner
hello
I have two datatables one called ScheduledOrdersTable and the other called AllOrdersTable which both have within them a field called OrderNO.
AllOrdersTable is the datasource for a datagrid on one of my forms.
what i want to do is remove/delete any row that occurs in the ScheduledOrdersTable from the AllOrdersTable, so that a row with a specific orderNo cannot occur in both tables.
this code returns a message saying there is no row at position 89
If ScheduledOrdersTable.Rows.Count > 0 Then
Dim d As Integer
For d = 0 To ScheduledOrdersTable.Rows.Count() - 1
Dim orderNo As String =ScheduledOrdersTable.Rows(d).Item("OrderNo")
Dim x As Integer
For x = 0 To AllOrdersTable.Rows.Count - 1
If AllOrdersTable.Rows(x).Item("ORDER_NUMBER") = orderNo Then
AllOrdersTable.Rows(x).Delete()
End If
Next
Next
End If
#
but if i change the line in red to:
For x = 0 To AllOrdersTable.Rows.Count - 2
all the rows that should be removed are except for the last row in the table
what i want to achive is surley quite simple can anybody help,
thanks in advance
alex
I have two datatables one called ScheduledOrdersTable and the other called AllOrdersTable which both have within them a field called OrderNO.
AllOrdersTable is the datasource for a datagrid on one of my forms.
what i want to do is remove/delete any row that occurs in the ScheduledOrdersTable from the AllOrdersTable, so that a row with a specific orderNo cannot occur in both tables.
this code returns a message saying there is no row at position 89
If ScheduledOrdersTable.Rows.Count > 0 Then
Dim d As Integer
For d = 0 To ScheduledOrdersTable.Rows.Count() - 1
Dim orderNo As String =ScheduledOrdersTable.Rows(d).Item("OrderNo")
Dim x As Integer
For x = 0 To AllOrdersTable.Rows.Count - 1
If AllOrdersTable.Rows(x).Item("ORDER_NUMBER") = orderNo Then
AllOrdersTable.Rows(x).Delete()
End If
Next
Next
End If
#
but if i change the line in red to:
For x = 0 To AllOrdersTable.Rows.Count - 2
all the rows that should be removed are except for the last row in the table
what i want to achive is surley quite simple can anybody help,
thanks in advance
alex