DataTableCollection.AddRange メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataTableCollection.AddRange メソッドの意味・解説 

DataTableCollection.AddRange メソッド

指定した DataTable 配列要素コレクション末尾コピーします

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

Public Sub AddRange ( _
    tables As DataTable() _
)
Dim instance As DataTableCollection
Dim tables As DataTable()

instance.AddRange(tables)
public void AddRange (
    DataTable[] tables
)
public:
void AddRange (
    array<DataTable^>^ tables
)
public void AddRange (
    DataTable[] tables
)
public function AddRange (
    tables : DataTable[]
)

パラメータ

tables

コレクション追加する DataTable オブジェクト配列

使用例使用例

2 つDataTable オブジェクト作成し、これらのオブジェクトDataSet の DataTableCollection に追加する例を次に示します

Public Sub DataTableCollectionAddRange()
    ' create a DataSet with two tables
    Dim dataSet As DataSet = New
 DataSet()

    ' create Customer table
    Dim customersTable As DataTable = New
 DataTable("Customers")
    customersTable.Columns.Add("customerId", _
           Type.GetType("System.Int32")).AutoIncrement
 = True
    customersTable.Columns.Add("name", Type.GetType("System.String"))
    customersTable.PrimaryKey = New DataColumn() _
           {customersTable.Columns("customerId")}

    ' create Orders table
    Dim ordersTable As DataTable = New
 DataTable("Orders")
    ordersTable.Columns.Add("orderId", _
           Type.GetType("System.Int32")).AutoIncrement
 = True
    ordersTable.Columns.Add("customerId", _
           Type.GetType("System.Int32"))
    ordersTable.Columns.Add("amount", _
           Type.GetType("System.Double"))
    ordersTable.PrimaryKey = New DataColumn() _
           {ordersTable.Columns("orderId")}

    dataSet.Tables.AddRange(New DataTable() {customersTable, ordersTable})

    ' print the tables and their columns
    Dim table As DataTable
    Dim column As DataColumn
    For Each table In dataSet.Tables
        Console.WriteLine(table.TableName)
        For Each column In
 table.Columns
            Console.Write("{0}" & vbTab, column.ColumnName)
        Next
        Console.WriteLine()
    Next
End Sub
public static void DataTableCollectionAddRange()
{
    // create a DataSet with two tables
    DataSet dataSet = new DataSet();

    // create Customer table
    DataTable customersTable = new DataTable("Customers");
    customersTable.Columns.Add("customerId",
        typeof(int)).AutoIncrement = true;
    customersTable.Columns.Add("name",
        typeof(string));
    customersTable.PrimaryKey = new DataColumn[] { customersTable.Columns["customerId"]
 };

    // create Orders table
    DataTable ordersTable = new DataTable("Orders");
    ordersTable.Columns.Add("orderId",
        typeof(int)).AutoIncrement = true;
    ordersTable.Columns.Add("customerId",
        typeof(int));
    ordersTable.Columns.Add("amount",
        typeof(double));
    ordersTable.PrimaryKey = new DataColumn[] { ordersTable.Columns["orderId"]
 };

    dataSet.Tables.AddRange(new DataTable[] { customersTable,
 ordersTable });

    // print the tables and their columns
    foreach (DataTable table in dataSet.Tables)
    {
        Console.WriteLine(table.TableName);
        foreach (DataColumn column in table.Columns)
        {
            Console.Write("{0}\table", column.ColumnName);
        }
        Console.WriteLine();
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataTableCollection クラス
DataTableCollection メンバ
System.Data 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataTableCollection.AddRange メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataTableCollection.AddRange メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataTableCollection.AddRange メソッド を検索

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

辞書ショートカット

すべての辞書の索引

DataTableCollection.AddRange メソッドのお隣キーワード
検索ランキング

   

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



DataTableCollection.AddRange メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS