Iterating API2 RowSet

I’m converting code from recordset to rowset and changing from recordset.movenext to iterating rows. I accidentally referenced RowSet.Column(“id”).IntegerValue rather than Row.Column(“id”).IntegerValue. However, I noticed that the values are the same.

In the code below, a and b are always the same for each iteration. Is this by design and is this something that can be relied on in the future?

[code]for each row as DatabaseRow in oRowset

a = row.column(“id”).IntegerValue
b = oRowset.column(“id”).IntegerValue

Next
[/code]

My guess would be that when iterating through the rowset movetonextrow needs to happen and you’re seeing the effect of that. I would suggest though that referencing your rowset in this loop wouldn’t be best practice.

I would suspect that rowset and recordset are referenging the same actual objects internally
so this makes sense that you could / would get this behaviour

however I would try to avoid it
unfortunately I doubt the compiler can help you in any way to avoid this

Norman, he’s not using RecordSet (just converting code that was using RecordSet). He is talking about referencing the RowSet directly within an iterator loop instead of via the Row iterator.

I believe Wayne’s reply is most likely the correct answer.

obviously I misread things :stuck_out_tongue:

for each row as DatabaseRow in oRowset
  
  a = row.column("id").IntegerValue
  b = oRowset.column("id").IntegerValue

Next

still oRowSet has to have some reference to “the current row” which “row” is also referring to and so either one just refers to the same underlying “data row object” - probably one that is hidden away from us

Thanks everyone. I suspect the same thing. This will not be a problem, as long as RowSet always show the current row. But if this behavior changes in the future, it will introduce some hard to track bugs.