Click to See Complete Forum and Search --> : CursorType Propety
qfmomen
Aug 31st, 2000, 12:22 AM
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.
Nina
Aug 31st, 2000, 03:51 AM
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
JHausmann
Sep 1st, 2000, 01:43 PM
select count(*) from table
will always give you the record count.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.