Help on adding new rows

Joined
Feb 13, 2009
Messages
12
Programming Experience
3-5
Need help! I'm sure I need something after .Add(newRow) I get an error that the row already exists.

VB.NET:
Public Class frmTeamParings
    Private Sub addPairings()
        Try
            Dim newRow As PairingsLeagueDataSet.tblParingsRow = Me.PairingsLeagueDataSet.tblParings.NewRow()
            Dim k As Integer = 1
            For i As Integer = 1 To 5
                For j As Integer = 1 To 10
                    k = j + 1
                    newRow.Week = i
                    newRow.TeamA = j
                    newRow.TeamB = k
                    Me.PairingsLeagueDataSet.tblParings.Rows.Add(newRow)
                   Next
            Next
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

Thanks,
 
Last edited:
Please use [ C O D E ] blocks in the future for readability.

VB.NET:
	Private Sub AddPairings()
		Try
			Dim newRow As PairingsLeagueDataSet.tblParingsRow
			Dim k As Integer = 1

			For i As Integer = 1 To 5
				For j As Integer = 1 To 10
					newRow = Me.PairingsLeagueDataSet.tblParings.NewRow
					k = j + 1
					newRow.Week = i
					newRow.TeamA = j
					newRow.Teamb = k
					Me.PairingsLeagueDataSet.tblParings.Rows.Add(newRow)
				Next
			Next
		Catch ex As Exception
			MessageBox.Show(ex.ToString())
		End Try
	End Sub
 

Latest posts

Back
Top