ADO: Recordset.RecordCount not working in SQL Server

  • Recordcount Ado:

    Note: This property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and -1 or the actual count for a dynamic cursor.

    Note: The Recordset object must be open when calling this property. If this property is not supported it will return -1.

    source:

    http://www.w3schools.com/ADO/prop_rs_recordcount.asp

    http://support.microsoft.com/kb/194973

  • Even in MSAccess you could not rely on the recordcount unless you had accessed all records in the recordset by doing a .movelast and then a .movefirst after opening the recordset. For a large dataset this can take some time

    To get a count without looping through the recordset, fire of a stored procedure that does a

    SELECT Count(*) as RecordCount FROM tblSourceTable

    and then check the value returned

Viewing 2 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply