Results 1 to 5 of 5

Thread: Looping through a record set

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Question

    Hi Guys
    I'm getting this error when I loop through a record set. I am connecting to a Stored Procedure that performs the search on my database. I can retrieve the first five set of records and then when there is no more data left in the table I get the following error.
    The Rowset was built over a live data feed and cannot be restarted
    Here is my loop
    Code:
    Do While objRS.EOF = False
    Call MsgBox((objRS.Fields(0) & vbNewLine & objRS.Fields(1) & vbNewLine & _
    objRS.Fields(2) & vbNewLine & objRS.Fields(3) & vbNewLine & objRS.Fields(4)), vbInformation)
    objRS.MoveNext
    Loop
    objRS.MoveFirst
    Can someone please help me
    JK

  2. #2
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Unhappy Hmmmm...

    I supsect you're having the same problem as me and I just started a thread on it before I read your thread:

    ADO Commands

    The problem is that sometimes stored procedures return 'forward only' recordsets. This must be dictated somehow by the structure (or nature) of the SP but I don't know what.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    the cursor type does not work as documented. I have the details somewhere and I will post them later.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Client side cursors are Static only and are adOpenForwardOnly. Changing to a different cursor type (adOpenKeyset, Dynamic or Static) will force the use of a Server Side cursor.

    Although Client-side cursors are static they can be updateable. They are useful for managing multiple record sets and using batch operations. The downside is that they are 'disconnected'.

    Server side are more flexible in type and quicker, and you can see updates in real time, handled by the Server and not you.

    Make sure you have the type you really need.

    Treat all of this information with caution as it refers to ADO in its earlier incarnations. Yours might be different

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  5. #5
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Smile Cheers, but...

    When opening a recordset like this:

    Code:
    SET rsSource = cmSource.Execute
    Where rsSource is a recordset and cmSource is a command (that is a stored procedure).

    The problem is that you don't get to specify the cursor type, lock type or cursor location.

    But, Since my last post, I have worked out how to do it.

    According to a document I found on ADO, this method of opening a recordset based on a SP, will always yield a read-only / forward only recordset.

    If you open it like this:

    Code:
    SET rsSource = New ADODB.Recordset
    rsSource.Open cmSource, , adOpenStatic, adLockReadOnly
    you can open the recordset in any manor you wish (the example opening a read-only static recordset.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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