Link to home
Start Free TrialLog in
Avatar of jasww
jasww

asked on

ado.net equivilant of recordset.MoveNext for DataSet

Hi
I can loop through all the rows in a dataset:
For each foo in bar.Dataset.Tables(0).Rows
  msgbox foo("id")
Next


I want to be able to step through and change rows, much like we can in vb6 with the RecordSet's MoveNext(), MoveFirst() etc methods.

I want to be able to do the following but in vb.net:

Do while not bar.Recordset.EOF()
    msgbox bar.recordset("id")
    bar.recordset.moveNext()
Loop



Thanks
Daniel
ASKER CERTIFIED SOLUTION
Avatar of Dexstar
Dexstar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jasww
jasww

ASKER

Yeah, I've ended up using that method.
I want to be able to advance a globally scoped dataset from anywhere within the code.
Using the For Each method I am tied to this section of the code, meaning all processing has to occur within the For Each loop.
Not a big deal, I just wondered if there was a better way.

Do you think this is a step backwards for .net?  I do.  I liked MovenNext().

Daniel
jasww:

> Do you think this is a step backwards for .net?  I do.  I liked MovenNext().

No, this is a step forward.  With the old style, the "current" record was a property of the recordset.  If you had 2 parts of your program trying to access 2 records at the same time, it will cause you grief because the first one will set the current record, and then the 2nd one will set the current record, and when the 1st part tries to read the data, it will read the record that the 2nd one set as current.  They conflict with each other.

With this technique, each part of the program can just get the record they want independently.  If you like MovenNext(), then you can just get the record that you want at any time with the Tables(0).Rows(n) command.

It is a little different, but you can still do whatever you need to do, and it is much more convenient for multithreaded applications.

Hope that helps,
Dex*
Avatar of Bob Learned
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: Dexstar {http:#9627995} & TheLearnedOne {http:#9628322}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
Avatar of jasww

ASKER

Sorry for not closing sooner.
Daniel