Howto move in a datatable rows

  • Thread starter Thread starter Erny
  • Start date Start date
E

Erny

Hi All,
I come from Microsoft Access programming,
so when I use a recordset from code, I can use
MoveFirst, MoveLast, MoveNext, MovePrevious
So my question is:
In a DataTable, how can I simulate this methods?
TIA
Erny
 
Erny,

A recordset and a datatable (not a dataset) are not much different in
behaviour.

A datatable holds datarows (and for the desciption of the items seperatly
which gives a different behaviour than the recordset datacolumns, which is
for your question not really relevant)

Therefore the first datarow from a datatable is
(I use VBNet notation because I assume that because you come from Microsoft
access where you use VBA)

dim dr as datarow = dt.rows(0)

The last one is (while I forget that dim etc)

dt.rows(dt.rows.count-1)

The second one is normally
dt.rows(currentindex + 1)

And the previous is the
dt.rows(currentindex - 1)

However, you can the best use databinding and you will use than the
currencymanager (current position manager), see for both of that the sample
on our website.

http://www.vb-tips.com/default.aspx?ID=c6c7d9a8-7511-41a1-a488-2e91e5295e7c

I hope this helps,

Cor
 
Back
Top