Aracılığıyla paylaş


DataTable Oluşturucular

Tanım

DataTable sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

Name Description
DataTable()

Bağımsız değişken olmadan sınıfının yeni bir örneğini DataTable başlatır.

DataTable(String)

Belirtilen tablo adıyla sınıfının yeni bir örneğini DataTable başlatır.

DataTable(SerializationInfo, StreamingContext)
Geçersiz.

Serileştirilmiş verilerle sınıfının yeni bir örneğini DataTable başlatır.

DataTable(String, String)

Belirtilen tablo adını ve ad alanını kullanarak sınıfın DataTable yeni bir örneğini başlatır.

DataTable()

Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs

Bağımsız değişken olmadan sınıfının yeni bir örneğini DataTable başlatır.

public:
 DataTable();
public DataTable();
Public Sub New ()

Örnekler

Aşağıdaki örnek ve DataRowile DataColumn yeni DataTable bir oluşturur ve bunu bir DataGridView denetimde görüntüler.

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;
}
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

Açıklamalar

Oluşturucu, nesnenin DataTable tüm özellikleri için ilk değerleri ayarlar. Aşağıdaki tabloda özellikler ve bunların varsayılan değerleri gösterilmektedir. Örneği DataTable oluşturulduğunda, aşağıdaki okuma/yazma özellikleri ilk değerlere ayarlanır.

Mülkiyet Varsayılan değer
CaseSensitive Üst DataSetöğeyle aynı, eğer birine aitse. Tersi durumda false.
Displayexpression Boş dize ("")
Locale Üst DataSet nesneninkiyle CultureInfo aynı (özellik tarafından Locale döndürülür); üst öğe yoksa varsayılan olarak geçerli sistemdir CultureInfo.
MinimumKapacity 50 satır.

Özelliğine ayrı bir çağrı ile bu özelliklerden herhangi birinin değerini değiştirebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

DataTable(String)

Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs

Belirtilen tablo adıyla sınıfının yeni bir örneğini DataTable başlatır.

public:
 DataTable(System::String ^ tableName);
public DataTable(string? tableName);
public DataTable(string tableName);
new System.Data.DataTable : string -> System.Data.DataTable
Public Sub New (tableName As String)

Parametreler

tableName
String

Tabloya vermek için gereken ad. null ise veya boş bir dizeysetableName, öğesine DataTableCollectioneklendiğinde varsayılan bir ad verilir.

Örnekler

Aşağıdaki örnek bir DataTable oluşturur ve bunu bir DataGridView denetimde görüntüler.

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;
}
Private Sub MakeDataTableAndDisplay()
   ' Create new DataTable.
   Dim table As 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

Ayrıca bkz.

Şunlara uygulanır

DataTable(SerializationInfo, StreamingContext)

Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs

Dikkat

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Serileştirilmiş verilerle sınıfının yeni bir örneğini DataTable başlatır.

protected:
 DataTable(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Members from serialized types may use dynamic code generation.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected DataTable(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Members from serialized types may use dynamic code generation.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")>]
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Data.DataTable : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Data.DataTable
new System.Data.DataTable : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Data.DataTable
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")>]
new System.Data.DataTable : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Data.DataTable
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")>]
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Data.DataTable : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Data.DataTable
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parametreler

info
SerializationInfo

Veri kümesi için serileştirilmiş veriler.

context
StreamingContext

Serileştirilmiş akış hakkında bağlamsal bilgiler.

Öznitelikler

Özel durumlar

Yalnızca .NET 7 ve sonraki sürümleri: info ikili verileri içerir.

Açıklamalar

Oluşturucunun DataTable bu uygulaması için ISerializablegereklidir.

Ayrıca bkz.

Şunlara uygulanır

DataTable(String, String)

Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs
Kaynak:
DataTable.cs

Belirtilen tablo adını ve ad alanını kullanarak sınıfın DataTable yeni bir örneğini başlatır.

public:
 DataTable(System::String ^ tableName, System::String ^ tableNamespace);
public DataTable(string? tableName, string? tableNamespace);
public DataTable(string tableName, string tableNamespace);
new System.Data.DataTable : string * string -> System.Data.DataTable
Public Sub New (tableName As String, tableNamespace As String)

Parametreler

tableName
String

Tabloya vermek için gereken ad. null ise veya boş bir dizeysetableName, öğesine DataTableCollectioneklendiğinde varsayılan bir ad verilir.

tableNamespace
String

içinde DataTabledepolanan verilerin XML gösterimi için ad alanı.

Ayrıca bkz.

Şunlara uygulanır