DataTable.Rows プロパティとは? わかりやすく解説

DataTable.Rows プロパティ

このテーブル属する行のコレクション取得します

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Dim instance As DataTable
Dim value As DataRowCollection

value = instance.Rows
public DataRowCollection Rows { get; }
public:
property DataRowCollection^ Rows {
    DataRowCollection^ get ();
}
/** @property */
public DataRowCollection get_Rows ()
public function get Rows
 () : DataRowCollection

プロパティ
DataRow オブジェクト格納されている DataRowCollection。DataRow オブジェクト存在しない場合null 値

解説解説
使用例使用例

行を返し設定する 2 つの例を次に示します最初の例では、Rows プロパティ使用し各行の各列の値を出力します2 番目の例では、DataTable オブジェクトNewRow メソッド使用してDataTableスキーマ新しDataRow オブジェクト作成します。行の値を設定した後、Add メソッド使用してこの行を DataRowCollection追加します

Private Sub PrintRows(dataSet As
 DataSet)
     ' For each table in the DataSet, print the values of each row.
     Dim thisTable As DataTable
     For Each thisTable In
  dataSet.Tables
         ' For each row, print the values of each column.
         Dim row As DataRow
         For Each row In
  thisTable.Rows
             Dim column As DataColumn
             For Each column In
  thisTable.Columns
                 Console.WriteLine(row(column))
             Next column
         Next row
     Next thisTable
End Sub
    
    
Private Sub AddARow(dataSet As
 DataSet)
    Dim table As DataTable = dataSet.Tables("Suppliers")
    ' Use the NewRow method to create a DataRow 
    'with the table's schema.
    Dim newRow As DataRow = table.NewRow()

    ' Set values in the columns:
    newRow("CompanyID") = "NewCompanyID"
    newRow("CompanyName") = "NewCompanyName"

    ' Add the row to the rows collection.
    table.Rows.Add(newRow)
End Sub
private void PrintRows(DataSet dataSet)
{
    // For each table in the DataSet, print the values of each row.
    foreach(DataTable thisTable in dataSet.Tables)
    {
        // For each row, print the values of each column.
        foreach(DataRow row in thisTable.Rows)
        {
            foreach(DataColumn column in thisTable.Columns)
            {
                Console.WriteLine(row[column]);
            }
        }
    }
}
 
 
private void AddARow(DataSet dataSet)
{
    DataTable table;
    table = dataSet.Tables["Suppliers"];
    // Use the NewRow method to create a DataRow with 
    // the table's schema.
    DataRow newRow = table.NewRow();

    // Set values in the columns:
    newRow["CompanyID"] = "NewCompanyID";
    newRow["CompanyName"] = "NewCompanyName";

    // Add the row to the rows collection.
    table.Rows.Add(newRow);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataTable クラス
DataTable メンバ
System.Data 名前空間
AcceptChanges
DataRow クラス
DataRowCollection クラス
NewRow
その他の技術情報
DataTable の作成使用



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataTable.Rows プロパティ」の関連用語

DataTable.Rows プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataTable.Rows プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS