I am having trouble (I believe) with a TableAdapter Update... or may also be incorrectly accessing and modifying a DataTable. I am not sure.
I hava a TableAdapter is attached to a form which is filled during the form_load sub with:
Code:Me.Tbl_MatchDataTableAdapter.Fill(Me.ScoreboardDataSet.tbl_MatchData)
Here is where I am screwing up… (I think)
I am accessing the DataTable directly with the following select command so that I can change the column data for “GameID” for a collection of rows.
The DataTable “tbl_MatchData” is updating. When trying to update the database with the new data I get the error: “Too many fields defined.” The TableAdapter.Update command works, because I use it on other forms. On this form, I only have the TableAdapter attached. I do not have any controls bound so I am not using a BindingSource (I am not sure if that matters to this discussion though).Code:Dim str_SQL as string = "GameID Like " & "'" & str_TestGameID & "'" Dim j As Integer = 0 Dim rows As DataRow() = Me.ScoreboardDataSet.tbl_MatchData.Select(str_SQL) For Each Mrow As DataRow In rows ‘check that the rows are updating j = CInt(Mrow("MatchNumber")) Console.WriteLine(j & ", " & str_NewGameID) Mrow("GameID") = str_NewGameID ‘update the GameID field with the new ID Console.WriteLine(Mrow("GameID")) Next
Code:Private Sub SaveAll() Me.Validate() Me.Tbl_GameDataBindingSource.EndEdit() Me.Tbl_GameDataTableAdapter.Update(Me.ScoreboardDataSet.tbl_GameData) Me.Tbl_DefaultDataBindingSource.EndEdit() Me.Tbl_DefaultDataTableAdapter.Update(Me.ScoreboardDataSet.tbl_DefaultData) Me.Tbl_MatchDataTableAdapter.Update(Me.ScoreboardDataSet.tbl_MatchData) <== Error here End Sub
Any guidance to this VB-Nobb is appreciated in advance.




Reply With Quote