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
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