I am trying to improve my understanding of accessing (selecting) rows from a DataTable. Below are three methods that I have tried and all seam to return expected results. There are no bound controls to the DataTable.
My question is: Which method is the preferred method to select rows from a DataTable and why? Better efficiency, or more predictable, easier to code?
Thanks to all who contribute to this great forum.
Code:EXAMPLE 1 str_SQL = "GameID Like " & "'" & str_CurentGameID & "'" Dim rows As DataRow() = Me.ScoreboardDataSet.tbl_MatchData.Select(str_SQL) For Each row As DataRow In rows row("GameID") = str_NewGameID NextCode:EXAMPLE 2 str_SQL = "GameID Like " & "'" & str_CurentGameID & "'" Me.ScoreboardDataSet.tbl_MatchData.DefaultView.RowFilter = str_SQL Dim row As DataRow For Each view As DataRowView In Me.ScoreboardDataSet.tbl_MatchData.DefaultView row = DirectCast(View.Row, DataRow) row("GameID") = str_NewGameID Next viewCode:EXAMPLE 3 For Each row As ScoreboardDataSet.tbl_MatchDataRow In Me.ScoreboardDataSet.tbl_MatchData.Select(String.Format("GameID LIKE '{0}'", str_CurentGameID)) row.GameID = str_NewGameID Next Mrow


Reply With Quote
