Results 1 to 21 of 21

Thread: ADO MoveFirst and NEXT

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ADO MoveFirst and NEXT

    Got an ADO RECORDSET and

    Did a move first...
    A Subsequent MOVE NEXT.. doesn't get me to the next record
    I have to do 2 MOVENEXT to get to it

    Any idea why?
    Is that a bug?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    It sound as if your provider moves to BOF instead of the first record when you call the MoveFirst method.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...would

    But I can actually look at the record after a movefirst...

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Yeah that is fully possible, a lot of providers return the first record when you stand on BOF as long as the recordset isn't empty.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    true

    but... Another subsequent next would yield the next record, I suppose... Not so..

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: ADO MoveFirst and NEXT

    Originally posted by Lafor
    Got an ADO RECORDSET and

    Did a move first...
    A Subsequent MOVE NEXT.. doesn't get me to the next record
    I have to do 2 MOVENEXT to get to it

    Any idea why?
    Is that a bug?
    do you have a blank record in the database?

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: true

    Originally posted by Lafor
    but... Another subsequent next would yield the next record, I suppose... Not so..
    No, if you stand on BOF a call to move next will move to the first record.
    VB Code:
    1. rs.MoveFirst
    2. If rs.BOF Then
    3.     rs.MoveNext
    4. End If

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Re: true

    Originally posted by Joacim Andersson
    No, if you stand on BOF a call to move next will move to the first record.
    VB Code:
    1. rs.MoveFirst
    2. If rs.BOF Then
    3.     rs.MoveNext
    4. End If
    but calling the .MoveFirst method puts you at the first record.. not before it

  9. #9
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: Re: Re: true

    Originally posted by kleinma
    but calling the .MoveFirst method puts you at the first record.. not before it
    Not really .... it puts the RecordPointer on BOF ... 1 before the first record. But as soon as you start reading it, it increases the record pointer by 1 automatically for the first time.

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Re: Re: Re: true

    Originally posted by techyspecy
    Not really .... it puts the RecordPointer on BOF ... 1 before the first record. But as soon as you start reading it, it increases the record pointer by 1 automatically for the first time.
    well what i am saying is if you do
    VB Code:
    1. RS.Open "SELECT BLAH FROM BLAH"
    2. RS.MoveFirst
    3. Do Until RS.EOF
    4.     Debug.Print RS(0)
    5.     RS.MoveNext
    6. Loop

    you will get all records without missing the first and without skipping any

  11. #11
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: Re: Re: Re: Re: true

    Originally posted by kleinma
    well what i am saying is if you do
    VB Code:
    1. RS.Open "SELECT BLAH FROM BLAH"
    2. RS.MoveFirst
    3. Do Until RS.EOF
    4.     Debug.Print RS(0)
    5.     RS.MoveNext
    6. Loop

    you will get all records without missing the first and without skipping any
    True - but that may not neccesarily mean that record 1 holds the record pointer when you do movefirst.

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Re: Re: true

    Originally posted by kleinma
    but calling the .MoveFirst method puts you at the first record.. not before it
    If you read the origional question and my first reply you'll see that it seems as if his provider is treating this wrong.

  13. #13
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: Re: Re: Re: true

    Originally posted by Joacim Andersson
    If you read the origional question and my first reply you'll see that it seems as if his provider is treating this wrong.
    Nothing is treating him wrong. Its absolutely right. He click on the button until he is on first record and first record gets displayed in the text boxes and then he clicks again which puts the record pointer in the BOF position. Mind you, first record is not BOF. BOF comes when you do MovePrevious on first record. Now he clicks the other button for movenext. When he clicks once, the record pointer comes on first record and first record is already displayed so it looks as if nothing has happened. When he clicks again the record pointer moves to 2nd record and 2nd record gets displayed and so on.

    There is nothing wrong with any provider or anything. This is ADO phenomenon and it has nothing to do with Providers.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ?..

    Think I found what the prob is

    This table for some reason has duplicate entries...
    And the way the original programmer wrote the code to navigate through the recordset was:

    Display current record
    Do a move first to get to the first record and
    and compare with the displayed record
    if same then do a move next

    and that would repeat everytime the > button is pressed..

  15. #15
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: ?..

    Originally posted by Lafor
    Think I found what the prob is

    This table for some reason has duplicate entries...
    And the way the original programmer wrote the code to navigate through the recordset was:

    Display current record
    Do a move first to get to the first record and
    and compare with the displayed record
    if same then do a move next

    and that would repeat everytime the > button is pressed..
    Check my last post .... there is nothing wrong with your code i think.

  16. #16
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Re: ?..

    Originally posted by techyspecy
    Check my last post .... there is nothing wrong with your code i think.
    MoveFirst followed by MoveNext should result in him standing on the the second record, right? In his origional post he said he didn't (though he probably is since he has duplicats in hid DB).

  17. #17
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Re: Re: ?..

    Originally posted by Joacim Andersson
    MoveFirst followed by MoveNext should result in him standing on the the second record, right? In his origional post he said he didn't (though he probably is since he has duplicats in hid DB).
    thats what im sayin

  18. #18
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Sorry guys, i thought he was talking about MovePrevious.

  19. #19
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Yeah but according to his origional question he was still standing on the first record after calling MoveNext.

  20. #20
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Well, he should probably put a text box on the form and do this ...

    on each movenext ...

    text1.text = Recordset.AbsolutePosition

    this will at least tell him whether recordset is moving or not ....

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...I gave a false explanation

    My fault..
    I gave a hasty and false assertion of what I thought was going on
    So...

    Thanks all for responding...

    On another note....[to change the subject]
    What a beautiful day it is around here!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width