I have a series of columns whose values will need to be updated based upon queries. I need to update starting from the first row and going through the last. The only way I could think to do this was to add a unique identifier to each row (basically a row number) and based on queries referencing this number, update the cell appropriately. The approach seems to work, but I don't know if it is the best solution. I will need to modify a number of other columns and will have to do it in a similar manner.
Here's the relevant code:
count = 0
For Each dtRow In dt.Rows 'I believe this is the main structure for updating all rows in table based on queries
Dim ThisYear = (From Row As DataRow In dt.Rows Where Row.Item("RowCnt") = count Select Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year).ToArray
Dim TotalYearsSum As UInt16 = (From Row As DataRow In dt.Rows Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year = ThisYear(0) _
Select Row.Field(Of UInteger)("HRBlk1")).Count 'Can Refer to a random Column. Will count all rows irrespective of value
dtRow.Item("YearFreq") = TotalYearsSum
count += 1
Next
Here's the relevant code:
count = 0
For Each dtRow In dt.Rows 'I believe this is the main structure for updating all rows in table based on queries
Dim ThisYear = (From Row As DataRow In dt.Rows Where Row.Item("RowCnt") = count Select Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year).ToArray
Dim TotalYearsSum As UInt16 = (From Row As DataRow In dt.Rows Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year = ThisYear(0) _
Select Row.Field(Of UInteger)("HRBlk1")).Count 'Can Refer to a random Column. Will count all rows irrespective of value
dtRow.Item("YearFreq") = TotalYearsSum
count += 1
Next
Last edited: