0

OK so I have a datagridview
I get information from a stored proceudre
this will have duplicates

How can I tidy up the code below which deletes duplciates?

'Ensure there are no duplicate SchoolChilds
        icountcount = dgvRegionalGrid.Rows.Count - 1
        iWaitTime = 10
        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next

        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next

        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next

        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next

        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next

        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next

        For icount = 1 To icountcount

            'Check SchoolChild ID delete Duplicates and then wait for  100th of a second

            If dgvRegionalGrid.Item("SchoolChild", icount).Value = dgvRegionalGrid.Item("SchoolChild", icount - 1).Value Then
                dgvRegionalGrid.Rows.RemoveAt(icount)
                
                
            End If

        Next
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Teme64
0

OMG. Can't you fix the sp? Like "SELECT DISTINCT(SchoolChildID)..." or "SELECT DISTINCT(SchoolChild)..."

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.