Results 1 to 3 of 3

Thread: CursorType Propety

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Lahore
    Posts
    9

    Talking

    I am using ADO recordset COURSORTYPE propeties.
    (1) When I set "rst.adOpenForwardOnly" and then I Check the "rst.RecordCount", The result is "-1" and if I do "rst.movelast" ,An Error message occures that Rowset cannot fetch records backwards.
    (2)When I set rst.adOpenKeyset the the recordcount is correct.
    (3)When I set rst.adOpenDynamic the the recordcount is -1.
    (4)When I set rst.adOpenStatic the the recordcount is -1.


    What is the problem with forwardOnly,Dynamic and static that in their situation recordCount gives -1.

    What is hell that rst.Movelast during forwardonly gives an error.

    Please Tell me About Cursor Types in detail Because It is an Assinment for me Given by MY BOSS.

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    84

    Quote from MSDN:
    Use the RecordCount property to find out how many records are in a Recordset object. The property returns -1 when ADO cannot determine the number of records or if the provider or cursor type does not support RecordCount. Reading the RecordCount property on a closed Recordset causes an error.

    If the Recordset object supports approximate positioning or bookmarks—that is, Supports (adApproxPosition) or Supports (adBookmark), respectively, return True—this value will be the exact number of records in the Recordset, regardless of whether it has been fully populated. If the Recordset object does not support approximate positioning, this property may be a significant drain on resources because all records will have to be retrieved and counted to return an accurate RecordCount value.

    The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.

    -------------------------------

    Use the MoveLast method to move the current record position to the last record in the Recordset. The Recordset object must support bookmarks or backward cursor movement; otherwise, the method call will generate an error.

    ...

    If the Recordset is forward only and you want to support both forward and backward scrolling, you can use the CacheSize property to create a record cache that will support backward cursor movement through the Move method. Because cached records are loaded into memory, you should avoid caching more records than is necessary. You can call the MoveFirst method in a forward-only Recordset object; doing so may cause the provider to re-execute the command that generated the Recordset object.
    hope, this helps


  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    select count(*) from table

    will always give you the record count.

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