DataTable コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataTable コンストラクタ ()の意味・解説 

DataTable コンストラクタ ()

引数指定せずに、DataTable クラス新しインスタンス初期化します。

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

解説解説
使用例使用例

DataColumn と DataRow で新しDataTable作成し、このテーブルを DataGridView コントロール表示する例を次に示します

Private Sub MakeDataTableAndDisplay()
   ' Create new DataTable.
   Dim table As New DataTable

   ' Declare DataColumn and DataRow variables.
   Dim column As DataColumn
   Dim row As DataRow

   ' Create new DataColumn, set DataType, ColumnName 
   ' and add to DataTable.    
   column = New DataColumn
   column.DataType = System.Type.GetType("System.Int32")
   column.ColumnName = "id"
   table.Columns.Add(column)

   ' Create second column.
   column = New DataColumn
   column.DataType = Type.GetType("System.String")
   column.ColumnName = "item"
   table.Columns.Add(column)

   ' Create new DataRow objects and add to DataTable.    
   Dim i As Integer
   For i = 0 To 10
      row = table.NewRow
      row("id") = i
      row("item") = "item "
 & i
      table.Rows.Add(row)
   Next i

   ' Set to DataGrid.DataSource property to the table.
   DataGrid1.DataSource = table
End Sub
private void MakeDataTableAndDisplay()
{
    // Create new DataTable.
    DataTable table = new DataTable();

    // Declare DataColumn and DataRow variables.
    DataColumn column;
    DataRow row;
 
    // Create new DataColumn, set DataType, ColumnName
    // and add to DataTable.    
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "id";
    table.Columns.Add(column);
 
    // Create second column.
    column = new DataColumn();
    column.DataType = Type.GetType("System.String");
    column.ColumnName = "item";
    table.Columns.Add(column);
 
    // Create new DataRow objects and add to DataTable.    
    for(int i = 0; i < 10; i++)
    {
        row = table.NewRow();
        row["id"] = i;
        row["item"] = "item " + i;
        table.Rows.Add(row);
    }
    // Set to DataGrid.DataSource property to the table.
    dataGrid1.DataSource = table;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataTable コンストラクタ (SerializationInfo, StreamingContext)

SerializationInfo と StreamingContext を使用して、DataTable クラス新しインスタンス初期化します。

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

Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New DataTable(info,
 context)
protected DataTable (
    SerializationInfo info,
    StreamingContext context
)
protected:
DataTable (
    SerializationInfo^ info, 
    StreamingContext context
)
protected DataTable (
    SerializationInfo info, 
    StreamingContext context
)
protected function DataTable (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

オブジェクトシリアル化または逆シリアル化必要なデータ

context

指定したシリアル化ストリーム転送元と転送先。

解説解説

この DataTable コンストラクタ実装は、ISerializable に必要です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataTable コンストラクタ (String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したテーブル名と名前空間使用して、DataTable クラス新しインスタンス初期化します。

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

Public Sub New ( _
    tableName As String, _
    tableNamespace As String _
)
Dim tableName As String
Dim tableNamespace As String

Dim instance As New DataTable(tableName,
 tableNamespace)
public DataTable (
    string tableName,
    string tableNamespace
)
public:
DataTable (
    String^ tableName, 
    String^ tableNamespace
)
public DataTable (
    String tableName, 
    String tableNamespace
)
public function DataTable (
    tableName : String, 
    tableNamespace : String
)

パラメータ

tableName

テーブルに付ける名前。null 参照 (Visual Basic では Nothing) または空の文字列場合は、DataTableCollection に追加したときに既定の名前が付けられます。

tableNamespace

DataTable格納されているデータXML 表現名前空間

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataTable コンストラクタ

DataTable クラス新しインスタンス初期化します。 DataTable の作成使用
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

DataTable クラス
DataTable メンバ
System.Data 名前空間

その他の技術情報

DataTable の作成使用
DataTable の作成使用

DataTable コンストラクタ (String)

指定したテーブル名を使用して DataTable クラス新しインスタンス初期化します。

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

Public Sub New ( _
    tableName As String _
)
Dim tableName As String

Dim instance As New DataTable(tableName)
public DataTable (
    string tableName
)
public:
DataTable (
    String^ tableName
)
public DataTable (
    String tableName
)
public function DataTable (
    tableName : String
)

パラメータ

tableName

テーブルに付ける名前。null 参照 (Visual Basic では Nothing) または空の文字列場合は、DataTableCollection に追加したときに既定の名前が付けられます。

使用例使用例

DataTable作成し、それを DataGridView コントロール表示する例を次に示します

Private Sub MakeDataTableAndDisplay()
   ' Create new DataTable.
   Dim table As DataTable = New
 DataTable("table")

   ' Declare DataColumn and DataRow variables.
   Dim column As DataColumn
   Dim row As DataRow

   ' Create new DataColumn, set DataType, 
   ' ColumnName and add to DataTable.    
   column = New DataColumn
   column.DataType = System.Type.GetType("System.Int32")
   column.ColumnName = "id"
   table.Columns.Add(column)

   ' Create second column.
   column = New DataColumn
   column.DataType = Type.GetType("System.String")
   column.ColumnName = "item"
   table.Columns.Add(column)

   ' Create new DataRow objects and add to DataTable.    
   Dim i As Integer
   For i = 0 To 10
      row = table.NewRow
      row("id") = i
      row("item") = "item "
 & i
      table.Rows.Add(row)
   Next i

   ' Set to DataGrid.DataSource property to the table.
   DataGrid1.DataSource = table
End Sub
private void MakeDataTableAndDisplay()
{
    // Create new DataTable.
    DataTable table = new DataTable("table");

    // Declare DataColumn and DataRow variables.
    DataColumn column;
    DataRow row;
 
    // Create new DataColumn, set DataType, 
    // ColumnName and add to DataTable.    
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "id";
    table.Columns.Add(column);
 
    // Create second column.
    column = new DataColumn();
    column.DataType = Type.GetType("System.String");
    column.ColumnName = "item";
    table.Columns.Add(column);
 
    // Create new DataRow objects and add to DataTable.    
    for(int i = 0; i < 10; i++)
    {
        row = table.NewRow();
        row["id"] = i;
        row["item"] = "item " + i;
        table.Rows.Add(row);
    }
    // Set to DataGrid.DataSource property to the table.
    dataGrid1.DataSource = table;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「DataTable コンストラクタ ()」の関連用語

DataTable コンストラクタ ()のお隣キーワード
検索ランキング

   

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



DataTable コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS