DataRowCollection クラス
アセンブリ: System.Data (system.data.dll 内)


DataRowCollection は DataTable の主要コンポーネントです。DataColumnCollection がテーブルのスキーマを定義するのに対して、DataRowCollection はテーブルの実際のデータを格納します。DataRowCollection に格納された各 DataRow は単一行を表します。
DataRowCollection に DataRow オブジェクトを挿入するには Add メソッドを呼び出し、オブジェクトを削除するには Remove メソッドを呼び出します。主キー列内の特定の値を格納する DataRow オブジェクトを検索するには Find メソッドを呼び出し、文字ベースのデータ内にある単一の単語または語句を検索するには Contains メソッドを呼び出します。

このセクションの最初の例では、DataRowCollection 内の各行の列 1 の値を出力します。2 番目の例では、NewRow メソッドを使用して作成した新しい行を 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
private void ShowRows(DataTable table) { // Print the number of rows in the collection. Console.WriteLine(table.Rows.Count); // Print the value of columns 1 in each row foreach(DataRow row in table.Rows) { Console.WriteLine(row[1]); } } private void AddRow(DataTable table) { DataRowCollection rowCollection = table.Rows; // Instantiate a new row using the NewRow method. DataRow newRow = table.NewRow(); // Insert code to fill the row with values. // Add the row to the DataRowCollection. table.Rows.Add(newRow); }

System.Data.InternalDataCollectionBase
System.Data.DataRowCollection


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataRowCollection クラスのページへのリンク