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.
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 |
See Also