Results 1 to 6 of 6

Thread: Getting the RecordCount

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Location
    Philippines
    Posts
    24

    Wink


    How can I get the record count value in an ADODB.Recordset object? It always returns a -1. Thanks.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You have to change the CursorLocation property to adUseClient before you open your recordset.

  3. #3
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    Have you tried using anything similar to this?

    Code:
    Dim cnn As Connection
    Dim rs As Recordset
    Dim rc As String
    
    
       .....
       .......
    
        Set rs = New Recordset
        rs.Open
        rc = rs.RecordCount
        Label1.Caption = rc
        rs.Close
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  4. #4
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    I've noticed that setting the ADO Recordset cursor to Static will return a record count (which makes sense, if the recordset changes, how can you count it?)

    Code:
    adoRset.Open "table", adoConn, adOpenStatic, adLockReadOnly

  5. #5
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    Use either adOpenKeyset or adOpenStatic as the CursorType for server side cursors, or use a client side cursor (since client side cursors use only adOpenStatic for CursorTypes).

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Location
    Philippines
    Posts
    24

    Lightbulb

    I'm opening the recordset with this statement:

    Rst.Open "SELECT * FROM <TABLE>", Conn, adOpenDynamic, adLockOptimistic, adCmdText

    Have tried Serge's tip and it worked! Thanks Serge and to the others who gave their tips....

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