# Recordset vs Rowset

**URL:** <https://forum.xojo.com/t/recordset-vs-rowset/50593>\
**Category:** Databases\
**Created:** [October 11, 2019, 8:11pm UTC](https://forum.xojo.com/t/recordset-vs-rowset/50593 "2019-10-11T20:11:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergio\_Tamborini](https://forum.xojo.com/user_avatar/forum.xojo.com/sergio_tamborini/32/729_2.png) [@Sergio\_Tamborini](https://forum.xojo.com/u/Sergio_Tamborini)\
**Post date:** [October 11, 2019, 8:11pm UTC](https://forum.xojo.com/t/recordset-vs-rowset/50593/1 "2019-10-11T20:11:05Z")

</div>

Hi all!

I’m approaching to new 2019r2, so I have a lot of “deprecate warnings”. One of my big problem is that recordsets return an 1 based array, and rowsets return a 0 based array. In some of my projects, I have a lot of recordsets and I use idxfield(x) to use some of the fields in the query. Now I have to correct about 20.000 rows in one of my biggest app, to avoid problems in the next future.  
My question is: do you know how to do this quickly without edit one row at time?

In most cases I use loops “for” to manage my query results, but in other cases I have rs.idxfield(2).value… rs.idxfield(19).datevalue… and I have a lot of probability to be in mistake correcting them manually as rs.idxfield(1).value… rs.idxfield(19).datevalue…

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [October 11, 2019, 8:49pm UTC](https://forum.xojo.com/t/recordset-vs-rowset/50593/2 "2019-10-11T20:49:18Z")

</div>

Deprecated does not mean gone. Recordset is going to be around a long time. Personally, I don’t think it’s worth converting an existing project to use API 2.0 because there’s no easy way to ensure you get it right. Going from 1-based to 0-based is not a trivial matter.

FWIW, I rarely, if ever use IDXField. I prefer referring to the field by name that way it doesn’t matter what order they are and if someone (maybe even you) inserts another field in the query it doesn’t throw off IDXField. Doesn’t help your situation now but the only time I use IDXField is I am literally bringing back 1 field and 1 field only.

---

<div class="post-metadata">

**Author:** ![Joseph\_E](https://forum.xojo.com/user_avatar/forum.xojo.com/joseph_e/32/613_2.png) [@Joseph\_E](https://forum.xojo.com/u/Joseph_E)\
**Post date:** [October 11, 2019, 8:51pm UTC](https://forum.xojo.com/t/recordset-vs-rowset/50593/3 "2019-10-11T20:51:55Z")

</div>

That’s unfortunate and I use the rs.idxfield(n).value as well, but I stopped quite a while ago because there are more problems with using that. Especially if you use something like Select \* from table. If the table structure ever changes you might get back an unexpected column.

Instead I suggest using rs.Field(“FieldName”).Value, or the new rowset.column. This way you are guaranteed to get the expected value back regardless of its position in the table or recordset. If you take the time to change all of your code that reference idxfield, it might be worthwhile to change it to reference the field name, rather than the index number.

And Bob beat me to it…

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://forum.xojo.com/user_avatar/forum.xojo.com/david_cox/32/227_2.png) [@David\_Cox](https://forum.xojo.com/u/David_Cox)\
**Post date:** [October 11, 2019, 8:55pm UTC](https://forum.xojo.com/t/recordset-vs-rowset/50593/4 "2019-10-11T20:55:29Z")

</div>

Sergio, I would have thought you would have used a while not rs.EOFrs.MoveNextWend loop. It is suggested we change to a for eachinnext loop, to be easier to read and no longer needs the rs.MoveNext.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:07pm UTC](https://forum.xojo.com/t/recordset-vs-rowset/50593/5 "2021-04-29T16:07:18Z")

</div>


