My final solution thanks to your input. Items added or modified by the program are now saved to the database.
Code:Private Sub UpdateLeaderboard(ByVal jName As String, jWins As Integer) Dim test As Boolean = False 'Check whether the name already exists Dim jRow As DataRow = SsrDataSet.JockeyLeaderboard.NewRow For XX = 0 To JockeyLeaderboardDataGridView.RowCount - 2 If jName = JockeyLeaderboardDataGridView.Rows(XX).Cells(1).Value.ToString Then jWins = JockeyLeaderboardDataGridView.Rows(XX).Cells(2).Value test = True jWins += 1 selRow = XX Exit For End If Next If test = True Then 'update the record with new info jWins += 1 Me.JockeyLeaderboardDataGridView.Rows(selRow).Cells(1).Value = jName Me.JockeyLeaderboardDataGridView.Rows(selRow).Cells(2).Value = jWins Else 'the name is not present so add it Dim MyNewRow As DataRow MyNewRow = SsrDataSet.JockeyLeaderboard.NewRow With MyNewRow .Item(1) = jName .Item(2) = jWins End With SsrDataSet.JockeyLeaderboard.Rows.Add(MyNewRow) End If Try Me.Validate() Me.JockeyLeaderboardBindingSource.EndEdit() Me.JockeyLeaderboardTableAdapter.Update(Me.SsrDataSet.JockeyLeaderboard) 'MsgBox("Update successful") Catch ex As Exception MsgBox(ex.ToString) End Try 'just added to make sure it is reading the database Me.JockeyLeaderboardTableAdapter.Dispose() Me.JockeyLeaderboardTableAdapter.Fill(Me.SsrDataSet.JockeyLeaderboard) End Sub




Reply With Quote
