dotConnect for DB2 Documentation
Devart.Common Namespace / DbDataTable Class / QueryRecordCount Property
Example

In This Topic
    QueryRecordCount Property
    In This Topic
    Determines whether DbDataTable should perfrom additional request to determine quantity of records in the result set.
    Syntax
    'Declaration
     
    Public Property QueryRecordCount As Boolean
    public bool QueryRecordCount {get; set;}

    Property Value

    If true, an additional request to server is executed, and the RecordCount is updated.
    Remarks
    The SQL statement for obtaining the record count is generated basing on the SelectCommand object. This property can be used when FetchAll is false, otherwise it is useless.
    Example
    The following example demonstrates how to use the QueryRecordCount property.
    static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) {
    
      myDataTable.Connection = myConnection;
      myDataTable.SelectCommand = myConnection.CreateCommand();
      myDataTable.SelectCommand.CommandText = "SELECT * FROM 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 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