DataTable 類別

定義

表示記憶體中資料的一個資料表。

public ref class DataTable : System::ComponentModel::MarshalByValueComponent, System::ComponentModel::IListSource, System::ComponentModel::ISupportInitialize, System::ComponentModel::ISupportInitializeNotification, System::Runtime::Serialization::ISerializable, System::Xml::Serialization::IXmlSerializable
public ref class DataTable
public ref class DataTable : System::ComponentModel::MarshalByValueComponent, System::ComponentModel::IListSource, System::ComponentModel::ISupportInitialize, System::Runtime::Serialization::ISerializable
public ref class DataTable : System::ComponentModel::MarshalByValueComponent, System::ComponentModel::IListSource, System::ComponentModel::ISupportInitializeNotification, System::Runtime::Serialization::ISerializable, System::Xml::Serialization::IXmlSerializable
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
public class DataTable
[System.Serializable]
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitialize, System.Runtime.Serialization.ISerializable
[System.Serializable]
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
public class DataTable : System.ComponentModel.MarshalByValueComponent, System.ComponentModel.IListSource, System.ComponentModel.ISupportInitializeNotification, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitialize
    interface ISupportInitializeNotification
    interface ISerializable
    interface IXmlSerializable
type DataTable = class
[<System.Serializable>]
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitialize
    interface ISerializable
[<System.Serializable>]
type DataTable = class
    inherit MarshalByValueComponent
    interface IListSource
    interface ISupportInitializeNotification
    interface ISupportInitialize
    interface ISerializable
    interface IXmlSerializable
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitialize, ISupportInitializeNotification, IXmlSerializable
Public Class DataTable
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitialize
Public Class DataTable
Inherits MarshalByValueComponent
Implements IListSource, ISerializable, ISupportInitializeNotification, IXmlSerializable
繼承
繼承
DataTable
衍生
屬性
實作

範例

下列範例會建立兩 DataTable 個 物件和一個 DataRelation 物件,並將新的 物件加入至 DataSet。 然後,數據表會顯示在控件中 DataGridView

// Put the next line into the Declarations section.
private System.Data.DataSet dataSet;

private void MakeDataTables()
{
    // Run all of the functions.
    MakeParentTable();
    MakeChildTable();
    MakeDataRelation();
    BindToDataGrid();
}

private void MakeParentTable()
{
    // Create a new DataTable.
    System.Data.DataTable table = new DataTable("ParentTable");
    // Declare variables for DataColumn and DataRow objects.
    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";
    column.ReadOnly = true;
    column.Unique = true;
    // Add the Column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.String");
    column.ColumnName = "ParentItem";
    column.AutoIncrement = false;
    column.Caption = "ParentItem";
    column.ReadOnly = false;
    column.Unique = false;
    // Add the column to the table.
    table.Columns.Add(column);

    // Make the ID column the primary key column.
    DataColumn[] PrimaryKeyColumns = new DataColumn[1];
    PrimaryKeyColumns[0] = table.Columns["id"];
    table.PrimaryKey = PrimaryKeyColumns;

    // Instantiate the DataSet variable.
    dataSet = new DataSet();
    // Add the new DataTable to the DataSet.
    dataSet.Tables.Add(table);

    // Create three new DataRow objects and add
    // them to the DataTable
    for (int i = 0; i <= 2; i++)
    {
        row = table.NewRow();
        row["id"] = i;
        row["ParentItem"] = "ParentItem " + i;
        table.Rows.Add(row);
    }
}

private void MakeChildTable()
{
    // Create a new DataTable.
    DataTable table = new DataTable("childTable");
    DataColumn column;
    DataRow row;

    // Create first column and add to the DataTable.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "ChildID";
    column.AutoIncrement = true;
    column.Caption = "ID";
    column.ReadOnly = true;
    column.Unique = true;

    // Add the column to the DataColumnCollection.
    table.Columns.Add(column);

    // Create second column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.String");
    column.ColumnName = "ChildItem";
    column.AutoIncrement = false;
    column.Caption = "ChildItem";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    // Create third column.
    column = new DataColumn();
    column.DataType = System.Type.GetType("System.Int32");
    column.ColumnName = "ParentID";
    column.AutoIncrement = false;
    column.Caption = "ParentID";
    column.ReadOnly = false;
    column.Unique = false;
    table.Columns.Add(column);

    dataSet.Tables.Add(table);

    // Create three sets of DataRow objects,
    // five rows each, and add to DataTable.
    for (int i = 0; i <= 4; i++)
    {
        row = table.NewRow();
        row["childID"] = i;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 0;
        table.Rows.Add(row);
    }
    for (int i = 0; i <= 4; i++)
    {
        row = table.NewRow();
        row["childID"] = i + 5;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 1;
        table.Rows.Add(row);
    }
    for (int i = 0; i <= 4; i++)
    {
        row = table.NewRow();
        row["childID"] = i + 10;
        row["ChildItem"] = "Item " + i;
        row["ParentID"] = 2;
        table.Rows.Add(row);
    }
}

private void MakeDataRelation()
{
    // DataRelation requires two DataColumn
    // (parent and child) and a name.
    DataColumn parentColumn =
        dataSet.Tables["ParentTable"].Columns["id"];
    DataColumn childColumn =
        dataSet.Tables["ChildTable"].Columns["ParentID"];
    DataRelation relation = new
        DataRelation("parent2Child", parentColumn, childColumn);
    dataSet.Tables["ChildTable"].ParentRelations.Add(relation);
}

private void BindToDataGrid()
{
    // Instruct the DataGrid to bind to the DataSet, with the
    // ParentTable as the topmost DataTable.
    DataGrid1.SetDataBinding(dataSet, "ParentTable");
}
' Put the next line into the Declarations section.
private dataSet As DataSet 
 
Private Sub MakeDataTables()
    ' Run all of the functions. 
    MakeParentTable()
    MakeChildTable()
    MakeDataRelation()
    BindToDataGrid()
End Sub
 
Private Sub MakeParentTable()
    ' Create a new DataTable.
    Dim table As New DataTable("ParentTable")

    ' Declare variables for DataColumn and DataRow objects.
    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"
    column.ReadOnly = True
    column.Unique = True

    ' Add the Column to the DataColumnCollection.
    table.Columns.Add(column)
 
    ' Create second column.
    column = New DataColumn()
    column.DataType = System.Type.GetType("System.String")
    column.ColumnName = "ParentItem"
    column.AutoIncrement = False
    column.Caption = "ParentItem"
    column.ReadOnly = False
    column.Unique = False

    ' Add the column to the table.
    table.Columns.Add(column)
 
    ' Make the ID column the primary key column.
    Dim PrimaryKeyColumns(0) As DataColumn
    PrimaryKeyColumns(0)= table.Columns("id")
    table.PrimaryKey = PrimaryKeyColumns
 
    ' Instantiate the DataSet variable.
    dataSet = New DataSet()

    ' Add the new DataTable to the DataSet.
    dataSet.Tables.Add(table)
 
    ' Create three new DataRow objects and add 
    ' them to the DataTable
    Dim i As Integer
    For i = 0 to 2
       row = table.NewRow()
       row("id") = i
       row("ParentItem") = "ParentItem " + i.ToString()
       table.Rows.Add(row)
    Next i
End Sub
 
Private Sub MakeChildTable()
    ' Create a new DataTable.
    Dim table As New DataTable("childTable")
    Dim column As DataColumn 
    Dim row As DataRow 
 
    ' Create first column and add to the DataTable.
    column = New DataColumn()
    column.DataType= System.Type.GetType("System.Int32")
    column.ColumnName = "ChildID"
    column.AutoIncrement = True
    column.Caption = "ID"
    column.ReadOnly = True
    column.Unique = True

    ' Add the column to the DataColumnCollection.
    table.Columns.Add(column)
 
    ' Create second column.
    column = New DataColumn()
    column.DataType= System.Type.GetType("System.String")
    column.ColumnName = "ChildItem"
    column.AutoIncrement = False
    column.Caption = "ChildItem"
    column.ReadOnly = False
    column.Unique = False
    table.Columns.Add(column)
 
    ' Create third column.
    column = New DataColumn()
    column.DataType= System.Type.GetType("System.Int32")
    column.ColumnName = "ParentID"
    column.AutoIncrement = False
    column.Caption = "ParentID"
    column.ReadOnly = False
    column.Unique = False
    table.Columns.Add(column)
 
    dataSet.Tables.Add(table)

    ' Create three sets of DataRow objects, five rows each, 
    ' and add to DataTable.
    Dim i As Integer
    For i = 0 to 4
       row = table.NewRow()
       row("childID") = i
       row("ChildItem") = "Item " + i.ToString()
       row("ParentID") = 0 
       table.Rows.Add(row)
    Next i
    For i = 0 to 4
       row = table.NewRow()
       row("childID") = i + 5
       row("ChildItem") = "Item " + i.ToString()
       row("ParentID") = 1 
       table.Rows.Add(row)
    Next i
    For i = 0 to 4
       row = table.NewRow()
       row("childID") = i + 10
       row("ChildItem") = "Item " + i.ToString()
       row("ParentID") = 2 
       table.Rows.Add(row)
    Next i
End Sub
 
Private Sub MakeDataRelation()
    ' DataRelation requires two DataColumn 
    ' (parent and child) and a name.
    Dim parentColumn As DataColumn = _
        dataSet.Tables("ParentTable").Columns("id")
    Dim childColumn As DataColumn = _
        dataSet.Tables("ChildTable").Columns("ParentID")
    Dim relation As DataRelation = new _
        DataRelation("parent2Child", parentColumn, childColumn)
    dataSet.Tables("ChildTable").ParentRelations.Add(relation)
End Sub
 
Private Sub BindToDataGrid()
    ' Instruct the DataGrid to bind to the DataSet, with the 
    ' ParentTable as the topmost DataTable.
    DataGrid1.SetDataBinding(dataSet,"ParentTable")
End Sub

備註

如需此 API 的詳細資訊,請參閱 DataTable 補充 API 備註

建構函式

DataTable()

不使用引數來初始化 DataTable 類別的新執行個體。

DataTable(SerializationInfo, StreamingContext)
已淘汰.

使用序列化資料,初始化 DataTable 類別的新執行個體。

DataTable(String)

使用指定的資料表名稱,初始化 DataTable 類別的新執行個體。

DataTable(String, String)

使用指定的資料表名稱和命名空間,初始化 DataTable 類別的新執行個體。

欄位

fInitInProgress

檢查初始化是否仍在進行中。 初始化發生於執行階段。

屬性

CaseSensitive

指示字串比較在資料表中是否區分大小寫。

ChildRelations

為這個 DataTable 取得子關聯的集合。

Columns

取得屬於這個資料表的資料行集合。

Constraints

取得這個資料表所維護的條件約束 (Constraint) 集合。

Container

取得元件的容器。

(繼承來源 MarshalByValueComponent)
DataSet

取得這個資料表所屬的 DataSet

DefaultView

取得可能含有已篩選檢視表或游標位置的資料表自訂檢視表。

DesignMode

取得值,表示元件目前是否處於設計模式。

(繼承來源 MarshalByValueComponent)
DisplayExpression

取得或設定會傳回用來在使用者介面中表示這個資料表之值的運算式。 DisplayExpression 屬性可讓您將這個資料表的名稱顯示在使用者介面中。

Events

取得附加在這個元件上的事件處理常式清單。

(繼承來源 MarshalByValueComponent)
ExtendedProperties

取得自訂使用者資訊的集合。

HasErrors

取得值,指出資料表所屬 DataSet 的任何資料表中的任何資料列是否存在錯誤。

IsInitialized

取得值,指出 DataTable 是否已初始化。

Locale

取得或設定用來在資料表中比較字串的地區設定 (Locale) 資訊。

MinimumCapacity

取得或設定這個資料表的初始開始大小。

Namespace

為在 DataTable 中所儲存資料的 XML 表示取得或設定命名空間。

ParentRelations

為這個 DataTable 取得父關聯的集合。

Prefix

為在 DataTable 中所儲存資料的 XML 表示取得或設定命名空間。

PrimaryKey

取得或設定資料行的陣列,這些資料行是做為資料表 (Data Table) 之主索引鍵。

RemotingFormat

取得或設定序列化格式。

Rows

取得屬於這個資料表的資料列集合。

Site

取得或設定 ISiteDataTable

TableName

取得或設定 DataTable 的名稱。

方法

AcceptChanges()

認可自前一次呼叫 AcceptChanges() 以來對這個資料表所做的所有變更。

BeginInit()

開始對表單或另一個元件所使用的 DataTable 進行初始化作業。 初始化發生於執行階段。

BeginLoadData()

載入資料時關閉告知、索引維護和條件約束。

Clear()

清除所有資料的 DataTable

Clone()

複製 (Clone) DataTable 的結構,包括所有 DataTable 結構描述和條件約束。

Compute(String, String)

計算在傳遞篩選準則的目前資料列上的指定運算式。

Copy()

複製這個 DataTable 的結構和資料。

CreateDataReader()

傳回對應於這個 DataTableReader 之中資料的 DataTable

CreateInstance()

建立 DataTable 的新執行個體。

Dispose()

釋放 MarshalByValueComponent 所使用的所有資源。

(繼承來源 MarshalByValueComponent)
Dispose(Boolean)

釋放 MarshalByValueComponent 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 MarshalByValueComponent)
EndInit()

結束對表單或另一個元件所使用的 DataTable 進行初始化作業。 初始化發生於執行階段。

EndLoadData()

載入資料後開啟告知、索引維護和條件約束。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetChanges()

取得 DataTable (包含從載入它或前一次呼叫 AcceptChanges() 以來所做的所有變更) 的複本。

GetChanges(DataRowState)

取得 DataTable (包含從前一次載入它或呼叫 AcceptChanges() 以來所做的所有變更) 的複本 (由 DataRowState 篩選)。

GetDataTableSchema(XmlSchemaSet)

這個方法會傳回 XmlSchemaSet 執行個體,此執行個體包含描述 Web 服務之 DataTable 的 Web 服務描述語言 (WSDL)。

GetErrors()

取得包含錯誤之 DataRow 物件的陣列。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)
已淘汰.

以序列化 DataTable 所需的資料,填入序列化資訊物件。

GetRowType()

取得資料列型別。

GetSchema()

如需這個成員的說明,請參閱 GetSchema()

GetService(Type)

取得 IServiceProvider 的實作器。

(繼承來源 MarshalByValueComponent)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
ImportRow(DataRow)

DataRow 複製至 DataTable,保留任何屬性設定,以及原始值和目前值。

Load(IDataReader)

使用所提供的 DataTable,用資料來源的值填滿 IDataReader。 如果 DataTable 已經包含資料列,從資料來源傳入的資料會與現有的資料列合併。

Load(IDataReader, LoadOption)

使用所提供的 DataTable,用資料來源的值填滿 IDataReader。 如果 DataTable 已經包含資料列,從資料來源傳入的資料會根據 loadOption 參數的值,與現有的資料列合併。

Load(IDataReader, LoadOption, FillErrorEventHandler)

使用所提供的 DataTable,以資料來源的值填滿 IDataReader,使用錯誤處理委派。

LoadDataRow(Object[], Boolean)

尋找並更新特定資料列。 如果找不到符合的資料列,則使用指定值來建立新的資料列。

LoadDataRow(Object[], LoadOption)

尋找並更新特定資料列。 如果找不到符合的資料列,則使用指定值來建立新的資料列。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Merge(DataTable)

將指定的 DataTable 與目前的 DataTable 合併。

Merge(DataTable, Boolean)

合併指定的 DataTable 與目前的 DataTable,指出是否保留目前 DataTable 中的變更。

Merge(DataTable, Boolean, MissingSchemaAction)

合併指定的 DataTable 與目前的 DataTable,指出是否保留變更,以及如何處理目前在 DataTable 中缺少的結構描述。

NewRow()

使用與資料表相同的結構描述來建立新的 DataRow

NewRowArray(Int32)

傳回 DataRow 的陣列。

NewRowFromBuilder(DataRowBuilder)

從現有的資料列建立新的資料列。

OnColumnChanged(DataColumnChangeEventArgs)

引發 ColumnChanged 事件。

OnColumnChanging(DataColumnChangeEventArgs)

引發 ColumnChanging 事件。

OnPropertyChanging(PropertyChangedEventArgs)

引發 PropertyChanged 事件。

OnRemoveColumn(DataColumn)

DataTable 通知 DataColumn 正在移除。

OnRowChanged(DataRowChangeEventArgs)

引發 RowChanged 事件。

OnRowChanging(DataRowChangeEventArgs)

引發 RowChanging 事件。

OnRowDeleted(DataRowChangeEventArgs)

引發 RowDeleted 事件。

OnRowDeleting(DataRowChangeEventArgs)

引發 RowDeleting 事件。

OnTableCleared(DataTableClearEventArgs)

引發 TableCleared 事件。

OnTableClearing(DataTableClearEventArgs)

引發 TableClearing 事件。

OnTableNewRow(DataTableNewRowEventArgs)

引發 TableNewRow 事件。

ReadXml(Stream)

使用指定的 DataTable,將 XML 結構描述和資料讀入 Stream

ReadXml(String)

將 XML 結構描述和資料從指定的檔案讀入 DataTable

ReadXml(TextReader)

使用指定的 DataTable,將 XML 結構描述和資料讀入 TextReader

ReadXml(XmlReader)

使用指定的 DataTable,將 XML 結構描述和資料讀入 XmlReader

ReadXmlSchema(Stream)

使用指定的資料流,將 XML 結構描述讀入 DataTable

ReadXmlSchema(String)

從指定的檔案,將 XML 結構描述讀入 DataTable

ReadXmlSchema(TextReader)

使用指定的 DataTable,將 XML 結構描述讀入 TextReader

ReadXmlSchema(XmlReader)

使用指定的 DataTable,將 XML 結構描述讀入 XmlReader

ReadXmlSerializable(XmlReader)

從 XML 資料流讀取。

RejectChanges()

復原從資料表載入以來,或前一次呼叫 AcceptChanges() 以來,對該資料表所做的所有變更。

Reset()

重設 DataTable 為它的原始狀態。 重設會移除資料表的所有資料、索引、關聯和資料行。 如果資料集包含 DataTable,則重設資料表之後,資料表仍將是資料集的一部分。

Select()

取得所有 DataRow 物件的陣列。

Select(String)

取得所有符合篩選準則之 DataRow 物件的陣列。

Select(String, String)

取得按照指定排序順序符合篩選條件的所有 DataRow 物件之陣列。

Select(String, String, DataViewRowState)

取得符合篩選條件 (按照排序順序,並符合指定狀態) 的所有 DataRow 物件之陣列。

ToString()

如果存在串連的字串,則取得 TableNameDisplayExpression

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
WriteXml(Stream)

使用指定的 Stream,將 DataTable 目前的內容寫入為 XML。

WriteXml(Stream, Boolean)

使用指定的 Stream,將 DataTable 目前的內容寫入為 XML。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXml(Stream, XmlWriteMode)

使用指定的 DataTable,寫入 XmlWriteMode 的目前資料 (並選擇性寫入結構描述) 至指定的檔案。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema

WriteXml(Stream, XmlWriteMode, Boolean)

使用指定的 DataTable,寫入 XmlWriteMode 的目前資料 (並選擇性寫入結構描述) 至指定的檔案。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXml(String)

使用指定的檔案,將 DataTable 目前的內容寫成 XML。

WriteXml(String, Boolean)

使用指定的檔案,將 DataTable 目前的內容寫成 XML。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXml(String, XmlWriteMode)

使用指定的檔案和 DataTable,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema

WriteXml(String, XmlWriteMode, Boolean)

使用指定的檔案和 DataTable,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXml(TextWriter)

使用指定的 TextWriter,將 DataTable 目前的內容寫入為 XML。

WriteXml(TextWriter, Boolean)

使用指定的 TextWriter,將 DataTable 目前的內容寫入為 XML。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXml(TextWriter, XmlWriteMode)

使用指定的 DataTableTextWriter,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema

WriteXml(TextWriter, XmlWriteMode, Boolean)

使用指定的 DataTableTextWriter,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXml(XmlWriter)

使用指定的 XmlWriter,將 DataTable 目前的內容寫入為 XML。

WriteXml(XmlWriter, Boolean)

使用指定的 XmlWriter,將 DataTable 目前的內容寫入為 XML。

WriteXml(XmlWriter, XmlWriteMode)

使用指定的 DataTableXmlWriter,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema

WriteXml(XmlWriter, XmlWriteMode, Boolean)

使用指定的 DataTableXmlWriter,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。 若要寫入結構描述,請設定 mode 參數的值為 WriteSchema。 若要儲存資料表及其所有子系的資料,請將 writeHierarchy 參數設定為 true

WriteXmlSchema(Stream)

DataTable 目前的資料結構撰寫成 XML 結構描述,寫入至指定的資料流。

WriteXmlSchema(Stream, Boolean)

DataTable 目前的資料結構撰寫成 XML 結構描述,寫入至指定的資料流。 若要儲存資料表及其所有子代的結構描述,請將 writeHierarchy 參數設定為 true

WriteXmlSchema(String)

DataTable 目前的資料結構撰寫成 XML 結構描述,寫入至指定的檔案。

WriteXmlSchema(String, Boolean)

DataTable 目前的資料結構撰寫成 XML 結構描述,寫入至指定的檔案。 若要儲存資料表及其所有子代的結構描述,請將 writeHierarchy 參數設定為 true

WriteXmlSchema(TextWriter)

使用指定的 DataTable,將 TextWriter 目前的資料結構撰寫成 XML 結構描述。

WriteXmlSchema(TextWriter, Boolean)

使用指定的 DataTable,將 TextWriter 目前的資料結構撰寫成 XML 結構描述。 若要儲存資料表及其所有子代的結構描述,請將 writeHierarchy 參數設定為 true

WriteXmlSchema(XmlWriter)

使用指定的 DataTable,將 XmlWriter 目前的資料結構撰寫成 XML 結構描述。

WriteXmlSchema(XmlWriter, Boolean)

使用指定的 DataTable,將 XmlWriter 目前的資料結構撰寫成 XML 結構描述。 若要儲存資料表及其所有子代的結構描述,請將 writeHierarchy 參數設定為 true

事件

ColumnChanged

發生在值已經為 DataColumn 中指定的 DataRow 變更之後。

ColumnChanging

發生在值正在為 DataColumn 中指定的 DataRow 變更之後。

Disposed

加入事件處理常式來接聽元件上的 Disposed 事件。

(繼承來源 MarshalByValueComponent)
Initialized

發生於 DataTable 初始化之後。

RowChanged

成功變更 DataRow 後發生。

RowChanging

發生在 DataRow 正在變更時。

RowDeleted

發生在資料表中的資料列已經刪除之後。

RowDeleting

發生在資料表中的資料列將要刪除之前。

TableCleared

發生在清除 DataTable 之後。

TableClearing

發生於清除 DataTable 時。

TableNewRow

發生在插入新的 DataRow 時。

明確介面實作

IListSource.ContainsListCollection

如需這個成員的說明,請參閱 ContainsListCollection

IListSource.GetList()

如需這個成員的說明,請參閱 GetList()

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

以序列化 DataTable 所需的資料,填入序列化資訊物件。

IXmlSerializable.GetSchema()

如需這個成員的說明,請參閱 GetSchema()

IXmlSerializable.ReadXml(XmlReader)

如需這個成員的說明,請參閱 ReadXml(XmlReader)

IXmlSerializable.WriteXml(XmlWriter)

如需這個成員的說明,請參閱 WriteXml(XmlWriter)

擴充方法

AsDataView(DataTable)

建立並傳回已啟用 LINQ 的 DataView 物件。

AsEnumerable(DataTable)

傳回 IEnumerable<T> 物件,其中泛型參數 TDataRow。 此物件可用於 LINQ 運算式或方法查詢。

適用於

執行緒安全性

此類型適用於多線程讀取作業。 您必須同步處理任何寫入作業。

另請參閱