DataRowCollection Class
Represents a collection of rows for a DataTable.
Assembly: System.Data (in System.Data.dll)
The DataRowCollection is a major component of the DataTable. While the DataColumnCollection defines the schema of the table, the DataRowCollection contains the actual data for the table, where each DataRow in the DataRowCollection represents a single row.
You can call the Add and Remove methods to insert and delete DataRow objects from the DataRowCollection. You can also call the Find method to search for DataRow objects that contain specific values in primary key columns, and the Contains method to search character-based data for single words or phrases.
The first example in this section prints the value of column 1 for every row in a DataRowCollection. The second example adds a new row created by using the NewRow method to the DataRowCollection.
Private Sub ShowRows(Byval table As DataTable) ' Print the number of rows in the collection. Console.WriteLine(table.Rows.Count) Dim row As DataRow ' Print the value of columns 1 in each row For Each row In table.Rows Console.WriteLine(row(1)) Next End Sub Private Sub AddRow(ByVal table As DataTable) ' Instantiate a new row using the NewRow method. Dim newRow As DataRow = table.NewRow() ' Insert code to fill the row with values. ' Add the row to the DataRowCollection. table.Rows.Add(newRow) End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.