dotConnect for SQL Server Documentation
Devart.Common Namespace / DbDataTable Class / RecordCount Property
Example

In This Topic
    RecordCount Property
    In This Topic
    Gets number of rows in the result set.
    Syntax
    'Declaration
     
    Public ReadOnly Property RecordCount As Integer
    public int RecordCount {get;}

    Property Value

    Number of rows in the result set. Meaning of this value depends on the QueryRecordCount property.
    Remarks
    If the QueryRecordCount property is true, the RecordCount property represents number of rows in the current result set. If the QueryRecordCount property is false, it is number of fetched rows.
    Example
    The following example demonstrates how to use the RecordCount property.
    static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) {
    
      myDataTable.Connection = myConnection;
      myDataTable.SelectCommand = myConnection.CreateCommand();
      myDataTable.SelectCommand.CommandText = "SELECT * FROM Test.Dept";
    
      myDataTable.QueryRecordCount = false;
      myDataTable.Active = true;
      int count = myDataTable.RecordCount; //the number of currently fetched rows
      myDataTable.Active = false;
    
      myDataTable.QueryRecordCount = true;
      myDataTable.Active = true;
      count = myDataTable.RecordCount; //the real number of rows in the table
      myDataTable.Active = false;
    }
    Private Shared Sub UseDataTable5(ByVal myDataTable As DbDataTable, ByVal myConnection As DbConnection)
      myDataTable.Connection = myConnection
      myDataTable.SelectCommand = myConnection.CreateCommand
      myDataTable.SelectCommand.CommandText = "SELECT * FROM Test.Dept"
      myDataTable.QueryRecordCount = False
    
      myDataTable.Active = True
      Dim num1 As Integer = myDataTable.RecordCount 'the number of currently fetched rows
    
      myDataTable.Active = False
      myDataTable.QueryRecordCount = True
    
      myDataTable.Active = True
      num1 = myDataTable.RecordCount 'the real number of rows in the table
    
      myDataTable.Active = False
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also