GetRowCount method

Returns a count of the number of rows in a table or result set. A threshold value is specified to avoid enumerating all rows in cases where it is only necessary to determine that there are more than a specific number of rows available. For example, an application that is displaying information from 10 rows may want to know if there are more than 10 rows available to be able to present an option for the user to display more information.

Syntax
Visual Basic
public int GetRowCount( _
ByVal threshold as Integer ) _ 
as Integer
C#
public int GetRowCount( int threshold );
Return value

If the threshold parameter is zero (no threshold), the return result is the number of rows in the table or result set; otherwise, the number of rows in the table or result set is returned up to a maximum of the threshold value.

Remarks

Enumerating all the rows in a table or result set can be an expensive operation for large tables or result sets. If an application only needs to know if there are more than a specific number of rows, this method can be used.