DataSet 類別

定義

代表資料的記憶體中快取。Represents an in-memory cache of data.

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

範例

下列範例包含數個從DataSet Northwind資料庫結合、建立和填入的方法。The following example consists of several methods that, combined, create and fill a DataSet from the Northwind database.

using System;
using System.Data;
using System.Data.SqlClient;

namespace Microsoft.AdoNet.DataSetDemo
{
    class NorthwindDataSet
    {
        static void Main()
        {
            string connectionString = GetConnectionString();
            ConnectToData(connectionString);
        }

        private static void ConnectToData(string connectionString)
        {
            //Create a SqlConnection to the Northwind database.
            using (SqlConnection connection =
                       new SqlConnection(connectionString))
            {
                //Create a SqlDataAdapter for the Suppliers table.
                SqlDataAdapter adapter = new SqlDataAdapter();

                // A table mapping names the DataTable.
                adapter.TableMappings.Add("Table", "Suppliers");

                // Open the connection.
                connection.Open();
                Console.WriteLine("The SqlConnection is open.");

                // Create a SqlCommand to retrieve Suppliers data.
                SqlCommand command = new SqlCommand(
                    "SELECT SupplierID, CompanyName FROM dbo.Suppliers;",
                    connection);
                command.CommandType = CommandType.Text;

                // Set the SqlDataAdapter's SelectCommand.
                adapter.SelectCommand = command;

                // Fill the DataSet.
                DataSet dataSet = new DataSet("Suppliers");
                adapter.Fill(dataSet);

                // Create a second Adapter and Command to get
                // the Products table, a child table of Suppliers. 
                SqlDataAdapter productsAdapter = new SqlDataAdapter();
                productsAdapter.TableMappings.Add("Table", "Products");

                SqlCommand productsCommand = new SqlCommand(
                    "SELECT ProductID, SupplierID FROM dbo.Products;",
                    connection);
                productsAdapter.SelectCommand = productsCommand;

                // Fill the DataSet.
                productsAdapter.Fill(dataSet);

                // Close the connection.
                connection.Close();
                Console.WriteLine("The SqlConnection is closed.");

                // Create a DataRelation to link the two tables
                // based on the SupplierID.
                DataColumn parentColumn =
                    dataSet.Tables["Suppliers"].Columns["SupplierID"];
                DataColumn childColumn =
                    dataSet.Tables["Products"].Columns["SupplierID"];
                DataRelation relation =
                    new System.Data.DataRelation("SuppliersProducts",
                    parentColumn, childColumn);
                dataSet.Relations.Add(relation);
                Console.WriteLine(
                    "The {0} DataRelation has been created.",
                    relation.RelationName);
            }
        }

        static private string GetConnectionString()
        {
            // To avoid storing the connection string in your code, 
            // you can retrieve it from a configuration file.
            return "Data Source=(local);Initial Catalog=Northwind;"
                + "Integrated Security=SSPI";
        }
    }
}
Option Explicit On
Option Strict On

Imports System.Data
Imports system.Data.SqlClient

Public Class NorthwindDataSet

    Public Shared Sub Main()
        Dim connectionString As String = _
            GetConnectionString()
        ConnectToData(connectionString)
    End Sub

    Private Shared Sub ConnectToData( _
        ByVal connectionString As String)

        ' Create a SqlConnection to the Northwind database.
        Using connection As SqlConnection = New SqlConnection( _
           connectionString)

            ' Create a SqlDataAdapter for the Suppliers table.
            Dim suppliersAdapter As SqlDataAdapter = _
               New SqlDataAdapter()

            ' A table mapping names the DataTable.
            suppliersAdapter.TableMappings.Add("Table", "Suppliers")

            ' Open the connection.
            connection.Open()
            Console.WriteLine("The SqlConnection is open.")

            ' Create a SqlCommand to retrieve Suppliers data.
            Dim suppliersCommand As New SqlCommand( _
               "SELECT SupplierID, CompanyName FROM dbo.Suppliers;", _
               connection)
            suppliersCommand.CommandType = CommandType.Text

            ' Set the SqlDataAdapter's SelectCommand.
            suppliersAdapter.SelectCommand = suppliersCommand

            ' Fill the DataSet.
            Dim dataSet As New DataSet("Suppliers")
            suppliersAdapter.Fill(dataSet)

            ' Create a second SqlDataAdapter and SqlCommand to get
            ' the Products table, a child table of Suppliers. 
            Dim productsAdapter As New SqlDataAdapter()
            productsAdapter.TableMappings.Add("Table", "Products")

            Dim productsCommand As New SqlCommand( _
               "SELECT ProductID, SupplierID FROM dbo.Products;", _
               connection)
            productsAdapter.SelectCommand = productsCommand

            ' Fill the DataSet.
            productsAdapter.Fill(dataSet)

            ' Close the connection.
            connection.Close()
            Console.WriteLine("The SqlConnection is closed.")

            ' Create a DataRelation to link the two tables
            ' based on the SupplierID.
            Dim parentColumn As DataColumn = _
               dataSet.Tables("Suppliers").Columns("SupplierID")
            Dim childColumn As DataColumn = _
               dataSet.Tables("Products").Columns("SupplierID")
            Dim relation As New DataRelation("SuppliersProducts", _
               parentColumn, childColumn)
            dataSet.Relations.Add(relation)

            Console.WriteLine( _
               "The {0} DataRelation has been created.", _
               relation.RelationName)
        End Using

    End Sub

    Private Shared Function GetConnectionString() As String
        ' To avoid storing the connection string in your code,  
        ' you can retrieve it from a configuration file.
        Return "Data Source=(local);Initial Catalog=Northwind;" _
           & "Integrated Security=SSPI;"
    End Function
End Class

備註

DataSet,這是從資料來源中抓取之資料的記憶體內部快取,是 ADO.NET 架構的主要元件。The DataSet, which is an in-memory cache of data retrieved from a data source, is a major component of the ADO.NET architecture. 包含物件的集合,您可以使用DataRelation物件彼此關聯。 DataTable DataSetThe DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects. 您也可以DataSet UniqueConstraint使用和ForeignKeyConstraint物件,在中強制執行資料完整性。You can also enforce data integrity in the DataSet by using the UniqueConstraint and ForeignKeyConstraint objects. 如需使用DataSet物件的詳細資訊,請參閱資料集、datatable 和 dataviewFor further details about working with DataSet objects, see DataSets, DataTables, and DataViews.

物件DataTable包含資料DataRelationCollection ,而則可讓您流覽資料表階層。Whereas DataTable objects contain the data, the DataRelationCollection allows you to navigate though the table hierarchy. 資料表包含在Tables透過屬性存取DataTableCollection的。The tables are contained in a DataTableCollection accessed through the Tables property. 存取DataTable物件時,請注意,它們會有條件地區分大小寫。When accessing DataTable objects, note that they are conditionally case sensitive. 例如,如果一個DataTable名稱為 "mydatatable",另一個名為 "mydatatable",則用來搜尋其中一個資料表的字串會被視為區分大小寫。For example, if one DataTable is named "mydatatable" and another is named "Mydatatable", a string used to search for one of the tables is regarded as case sensitive. 不過,如果 "mydatatable" 存在,而且 "Mydatatable" 不是,則會將搜尋字串視為不區分大小寫。However, if "mydatatable" exists and "Mydatatable" does not, the search string is regarded as case insensitive. 如需使用DataTable物件的詳細資訊,請參閱建立 DataTableFor more information about working with DataTable objects, see Creating a DataTable.

DataSet可以讀取和寫入資料和架構做為 XML 檔。A DataSet can read and write data and schema as XML documents. 然後,資料和架構可以透過 HTTP 傳輸,並由任何應用程式在任何啟用 XML 的平臺上使用。The data and schema can then be transported across HTTP and used by any application, on any platform that is XML-enabled. 您可以使用WriteXmlSchema方法將架構儲存為 XML 架構,而且可以WriteXml使用方法來儲存架構和資料。You can save the schema as an XML schema with the WriteXmlSchema method, and both schema and data can be saved using the WriteXml method. 若要讀取同時包含架構和資料的 XML 檔,請使用ReadXml方法。To read an XML document that includes both schema and data, use the ReadXml method.

在典型的多層式執行中,建立和DataSet重新整理,然後再更新原始資料的步驟如下:In a typical multiple-tier implementation, the steps for creating and refreshing a DataSet, and in turn, updating the original data are to:

  1. 使用DataTable 從資料DataSet源中的資料,建立並填入中的每個。 DataAdapterBuild and fill each DataTable in a DataSet with data from a data source using a DataAdapter.

  2. 藉由新增、更新DataTable或刪除DataRow物件,變更個別物件中的資料。Change the data in individual DataTable objects by adding, updating, or deleting DataRow objects.

  3. 叫用DataSet方法來建立第二個,只提供資料變更的功能。 GetChangesInvoke the GetChanges method to create a second DataSet that features only the changes to the data.

  4. 呼叫的DataAdapter DataSet方法,並傳遞第二個做為引數。 UpdateCall the Update method of the DataAdapter, passing the second DataSet as an argument.

  5. 叫用DataSet方法,將第二個變更合併到第一個。 MergeInvoke the Merge method to merge the changes from the second DataSet into the first.

  6. 叫用AcceptChanges DataSet上的。Invoke the AcceptChanges on the DataSet. 或者, RejectChanges叫用以取消變更。Alternatively, invoke RejectChanges to cancel the changes.

注意

和物件繼承MarshalByValueComponent自,而且支援介面以進行遠端處理。ISerializable DataSet DataTableThe DataSet and DataTable objects inherit from MarshalByValueComponent, and support the ISerializable interface for remoting. 這些是唯一可以進行遠端通訊的 ADO.NET 物件。These are the only ADO.NET objects that can be remoted.

注意

繼承自DataSet的類別不是由垃圾收集行程完成,因為已在中抑制完成DataSet項。Classes inherited from DataSet are not finalized by the garbage collector, because the finalizer has been suppressed in DataSet. 衍生的類別可以呼叫其ReRegisterForFinalize函式中的方法,以允許垃圾收集行程完成類別。The derived class can call the ReRegisterForFinalize method in its constructor to allow the class to be finalized by the garbage collector.

建構函式

DataSet()

初始化 DataSet 類別的新執行個體。Initializes a new instance of the DataSet class.

DataSet(SerializationInfo, StreamingContext)

初始化具有指定序列化資訊和內容之 DataSet 類別的新執行個體。Initializes a new instance of a DataSet class that has the given serialization information and context.

DataSet(SerializationInfo, StreamingContext, Boolean)

初始化 DataSet 類別的新執行個體。Initializes a new instance of the DataSet class.

DataSet(String)

使用指定名稱,初始化 DataSet 類別的新執行個體。Initializes a new instance of a DataSet class with the given name.

屬性

CaseSensitive

取得或設定值,指出在 DataTable 物件中的字串比較是否為區分大小寫。Gets or sets a value indicating whether string comparisons within DataTable objects are case-sensitive.

Container

取得元件的容器。Gets the container for the component.

(繼承來源 MarshalByValueComponent)
DataSetName

取得或設定目前 DataSet 的名稱。Gets or sets the name of the current DataSet.

DefaultViewManager

取得 DataSet (它允許使用自訂的 DataViewManager 進行篩選、搜尋和巡覽) 所包含的資料之自訂檢視。Gets a custom view of the data contained in the DataSet to allow filtering, searching, and navigating using a custom DataViewManager.

DesignMode

取得值,表示元件目前是否處於設計模式。Gets a value indicating whether the component is currently in design mode.

(繼承來源 MarshalByValueComponent)
EnforceConstraints

取得或設定值,指出在嘗試任何更新作業時,是否遵循條件約束 (Constraint) 規則。Gets or sets a value indicating whether constraint rules are followed when attempting any update operation.

Events

取得附加在這個元件上的事件處理常式清單。Gets the list of event handlers that are attached to this component.

(繼承來源 MarshalByValueComponent)
ExtendedProperties

取得與 DataSet 相關聯的自訂使用者資訊集合。Gets the collection of customized user information associated with the DataSet.

HasErrors

取得值,指出這個 DataTable 內的 DataSet 物件中是否有任何一個有錯誤。Gets a value indicating whether there are errors in any of the DataTable objects within this DataSet.

IsInitialized

取得值,指出 DataSet 是否已初始化。Gets a value that indicates whether the DataSet is initialized.

Locale

取得或設定用來在資料表中比較字串的地區設定 (Locale) 資訊。Gets or sets the locale information used to compare strings within the table.

Namespace

取得或設定 DataSet 的命名空間。Gets or sets the namespace of the DataSet.

Prefix

取得或設定建立 DataSet 命名空間別名的 XML 前置詞。Gets or sets an XML prefix that aliases the namespace of the DataSet.

Relations

取得關聯的集合,這些關聯會連結資料表,並允許從父資料表巡覽至子資料表。Gets the collection of relations that link tables and allow navigation from parent tables to child tables.

RemotingFormat

取得或設定遠端作業中使用之 SerializationFormatDataSetGets or sets a SerializationFormat for the DataSet used during remoting.

SchemaSerializationMode

取得或設定 SchemaSerializationModeDataSetGets or sets a SchemaSerializationMode for a DataSet.

Site

取得或設定 ISiteDataSetGets or sets an ISite for the DataSet.

Tables

取得包含在 DataSet 中的資料表的集合。Gets the collection of tables contained in the DataSet.

方法

AcceptChanges()

認可從載入這個 DataSet 物件或前一次呼叫 AcceptChanges() 以來,對該物件做的所有變更。Commits all the changes made to this DataSet since it was loaded or since the last time AcceptChanges() was called.

BeginInit()

開始對表單或另一個元件所使用的 DataSet 進行初始化作業。Begins the initialization of a DataSet that is used on a form or used by another component. 初始化發生於執行階段。The initialization occurs at run time.

Clear()

移除所有資料表中的資料列,以清除任何資料的 DataSetClears the DataSet of any data by removing all rows in all tables.

Clone()

複製 DataSet 的結構,包括所有 DataTable 結構描述、關聯和條件約束。Copies the structure of the DataSet, including all DataTable schemas, relations, and constraints. 不要複製任何資料。Does not copy any data.

Copy()

複製這個 DataSet 的結構和資料。Copies both the structure and data for this DataSet.

CreateDataReader()

傳回 DataTableReader,每個 DataTable 有一個結果集,順序與資料表出現在 Tables 集合中的順序相同。Returns a DataTableReader with one result set per DataTable, in the same sequence as the tables appear in the Tables collection.

CreateDataReader(DataTable[])

傳回 DataTableReader,每一個 DataTable 有一個結果集。Returns a DataTableReader with one result set per DataTable.

DetermineSchemaSerializationMode(SerializationInfo, StreamingContext)

判斷 SchemaSerializationModeDataSetDetermines the SchemaSerializationMode for a DataSet.

DetermineSchemaSerializationMode(XmlReader)

判斷 SchemaSerializationModeDataSetDetermines the SchemaSerializationMode for a DataSet.

Dispose()

釋放 MarshalByValueComponent 所使用的所有資源。Releases all resources used by the MarshalByValueComponent.

(繼承來源 MarshalByValueComponent)
Dispose(Boolean)

釋放 MarshalByValueComponent 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the MarshalByValueComponent and optionally releases the managed resources.

(繼承來源 MarshalByValueComponent)
EndInit()

結束對表單或另一個元件所使用的 DataSet 進行初始化作業。Ends the initialization of a DataSet that is used on a form or used by another component. 初始化發生於執行階段。The initialization occurs at run time.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetChanges()

取得 DataSet (包含從載入它或前一次呼叫 AcceptChanges() 以來所做的所有變更) 的複本。Gets a copy of the DataSet that contains all changes made to it since it was loaded or since AcceptChanges() was last called.

GetChanges(DataRowState)

取得 DataSet (包含從前一次載入它或呼叫 AcceptChanges() 以來所做的所有變更) 的複本 (由 DataRowState 篩選)。Gets a copy of the DataSet containing all changes made to it since it was last loaded, or since AcceptChanges() was called, filtered by DataRowState.

GetDataSetSchema(XmlSchemaSet)

取得資料集之 XmlSchemaSet 的複本。Gets a copy of XmlSchemaSet for the DataSet.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)

以序列化 DataSet 所需的資料,填入序列化資訊物件。Populates a serialization information object with the data needed to serialize the DataSet.

GetSchemaSerializable()

傳回可序列化的 XmlSchema 執行個體。Returns a serializable XmlSchema instance.

GetSerializationData(SerializationInfo, StreamingContext)

從二進位或 XML 資料流還原序列化資料表資料。Deserializes the table data from the binary or XML stream.

GetService(Type)

取得 IServiceProvider 的實作器。Gets the implementer of the IServiceProvider.

(繼承來源 MarshalByValueComponent)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetXml()

傳回儲存於 DataSet 的資料之 XML 表示。Returns the XML representation of the data stored in the DataSet.

GetXmlSchema()

為儲存於 DataSet 的資料之 XML 表示,傳回 XML 結構描述。Returns the XML Schema for the XML representation of the data stored in the DataSet.

HasChanges()

取得值,表示 DataSet 是否包含變更,包括加入、刪除或修改的資料列。Gets a value indicating whether the DataSet has changes, including new, deleted, or modified rows.

HasChanges(DataRowState)

取得值,指出 DataSet 是否包含變更,包括加入、刪除或修改的資料列 (由 DataRowState 篩選)。Gets a value indicating whether the DataSet has changes, including new, deleted, or modified rows, filtered by DataRowState.

InferXmlSchema(Stream, String[])

從指定的 Stream,將 XML 結構描述套用至 DataSetApplies the XML schema from the specified Stream to the DataSet.

InferXmlSchema(String, String[])

從指定的檔案,將 XML 結構描述套用至 DataSetApplies the XML schema from the specified file to the DataSet.

InferXmlSchema(TextReader, String[])

從指定的 TextReader,將 XML 結構描述套用至 DataSetApplies the XML schema from the specified TextReader to the DataSet.

InferXmlSchema(XmlReader, String[])

從指定的 XmlReader,將 XML 結構描述套用至 DataSetApplies the XML schema from the specified XmlReader to the DataSet.

InitializeDerivedDataSet()

從二進位或 XML 資料流還原序列化資料集的所有資料表資料。Deserialize all of the tables data of the DataSet from the binary or XML stream.

IsBinarySerialized(SerializationInfo, StreamingContext)

檢查 DataSet 之序列化表示的格式。Inspects the format of the serialized representation of the DataSet.

Load(IDataReader, LoadOption, DataTable[])

使用所提供的 DataSet,以資料來源的值,填入 IDataReader,使用 DataTable 執行個體的陣列,以提供結構描述和命名空間資訊。Fills a DataSet with values from a data source using the supplied IDataReader, using an array of DataTable instances to supply the schema and namespace information.

Load(IDataReader, LoadOption, FillErrorEventHandler, DataTable[])

使用所提供的 DataSet,以資料來源的值,填入 IDataReader,使用 DataTable 執行個體的陣列,以提供結構描述和命名空間資訊。Fills a DataSet with values from a data source using the supplied IDataReader, using an array of DataTable instances to supply the schema and namespace information.

Load(IDataReader, LoadOption, String[])

使用所提供的 DataSet,以資料來源的值填入 IDataReader,使用字串的陣列來提供 DataSet 之內的資料表名稱。Fills a DataSet with values from a data source using the supplied IDataReader, using an array of strings to supply the names for the tables within the DataSet.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Merge(DataRow[])

DataRow 物件的陣列合併到目前的 DataSet 中。Merges an array of DataRow objects into the current DataSet.

Merge(DataRow[], Boolean, MissingSchemaAction)

DataRow 物件的陣列合併到目前的 DataSet 中,根據給定參數保留或忽略 DataSet 中的變更,並處理不相容的結構描述。Merges an array of DataRow objects into the current DataSet, preserving or discarding changes in the DataSet and handling an incompatible schema according to the given arguments.

Merge(DataSet)

將指定的 DataSet 及其結構描述合併到目前的 DataSet 中。Merges a specified DataSet and its schema into the current DataSet.

Merge(DataSet, Boolean)

將指定的 DataSet 及其結構描述合併到目前的 DataSet 中,根據給定參數保留或忽略這個 DataSet 中的任何變更。Merges a specified DataSet and its schema into the current DataSet, preserving or discarding any changes in this DataSet according to the given argument.

Merge(DataSet, Boolean, MissingSchemaAction)

將指定的 DataSet 及其結構描述與目前的 DataSet 合併,根據給定參數保留或忽略目前 DataSet 中的變更,並處理不相容的結構描述。Merges a specified DataSet and its schema with the current DataSet, preserving or discarding changes in the current DataSet and handling an incompatible schema according to the given arguments.

Merge(DataTable)

將指定的 DataTable 及其結構描述合併到目前的 DataSet 中。Merges a specified DataTable and its schema into the current DataSet.

Merge(DataTable, Boolean, MissingSchemaAction)

將指定的 DataTable 及其結構描述合併到目前的 DataSet,根據給定引數保留或忽略 DataSet 中的變更,並處理不相容的結構描述。Merges a specified DataTable and its schema into the current DataSet, preserving or discarding changes in the DataSet and handling an incompatible schema according to the given arguments.

OnPropertyChanging(PropertyChangedEventArgs)

引發 OnPropertyChanging(PropertyChangedEventArgs) 事件。Raises the OnPropertyChanging(PropertyChangedEventArgs) event.

OnRemoveRelation(DataRelation)

發生於從 DataRelation 移除 DataTable 時。Occurs when a DataRelation object is removed from a DataTable.

OnRemoveTable(DataTable)

發生於從 DataTable 移除 DataSet 時。Occurs when a DataTable is removed from a DataSet.

RaisePropertyChanging(String)

傳送一個指定的 DataSet 屬性即將變更的告知。Sends a notification that the specified DataSet property is about to change.

ReadXml(Stream)

使用指定的 DataSet,將 XML 結構描述和資料讀入 StreamReads XML schema and data into the DataSet using the specified Stream.

ReadXml(Stream, XmlReadMode)

使用指定的 DataSetStream,將 XML 結構描述和資料讀入 XmlReadModeReads XML schema and data into the DataSet using the specified Stream and XmlReadMode.

ReadXml(String)

使用指定的檔案,將 XML 結構描述和資料讀入 DataSetReads XML schema and data into the DataSet using the specified file.

ReadXml(String, XmlReadMode)

使用指定的檔案和 DataSet,將 XML 結構描述和資料讀入 XmlReadModeReads XML schema and data into the DataSet using the specified file and XmlReadMode.

ReadXml(TextReader)

使用指定的 DataSet,將 XML 結構描述和資料讀入 TextReaderReads XML schema and data into the DataSet using the specified TextReader.

ReadXml(TextReader, XmlReadMode)

使用指定的 DataSetTextReader,將 XML 結構描述和資料讀入 XmlReadModeReads XML schema and data into the DataSet using the specified TextReader and XmlReadMode.

ReadXml(XmlReader)

使用指定的 DataSet,將 XML 結構描述和資料讀入 XmlReaderReads XML schema and data into the DataSet using the specified XmlReader.

ReadXml(XmlReader, XmlReadMode)

使用指定的 DataSetXmlReader,將 XML 結構描述和資料讀入 XmlReadModeReads XML schema and data into the DataSet using the specified XmlReader and XmlReadMode.

ReadXmlSchema(Stream)

從指定的 Stream,將 XML 結構描述讀入 DataSetReads the XML schema from the specified Stream into the DataSet.

ReadXmlSchema(String)

從指定的檔案,將 XML 結構描述讀入 DataSetReads the XML schema from the specified file into the DataSet.

ReadXmlSchema(TextReader)

從指定的 TextReader,將 XML 結構描述讀入 DataSetReads the XML schema from the specified TextReader into the DataSet.

ReadXmlSchema(XmlReader)

從指定的 XmlReader,將 XML 結構描述讀入 DataSetReads the XML schema from the specified XmlReader into the DataSet.

ReadXmlSerializable(XmlReader)

忽略屬性並傳回空白資料集。Ignores attributes and returns an empty DataSet.

RejectChanges()

復原從建立 DataSet 物件或前一次呼叫 AcceptChanges() 以來,對該物件做的所有變更。Rolls back all the changes made to the DataSet since it was created, or since the last time AcceptChanges() was called.

Reset()

清除所有資料表,並從 DataSet 中移除所有關聯、外部條件約束和資料表。Clears all tables and removes all relations, foreign constraints, and tables from the DataSet. 子類別應該覆寫 Reset() 以還原 DataSet 到它的原始狀態。Subclasses should override Reset() to restore a DataSet to its original state.

ShouldSerializeRelations()

取得值,表示是否應該保存 Relations 屬性。Gets a value indicating whether Relations property should be persisted.

ShouldSerializeTables()

取得值,表示是否應該保存 Tables 屬性。Gets a value indicating whether Tables property should be persisted.

ToString()

傳回任何包含 Component 名稱的 StringReturns a String containing the name of the Component, if any. 不應覆寫此方法。This method should not be overridden.

(繼承來源 MarshalByValueComponent)
WriteXml(Stream)

使用指定的 DataSet,寫入 Stream 的目前資料。Writes the current data for the DataSet using the specified Stream.

WriteXml(Stream, XmlWriteMode)

使用指定的 DataSetStream,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。Writes the current data, and optionally the schema, for the DataSet using the specified Stream and XmlWriteMode. 若要寫入結構描述,請設定 mode 參數的值為 WriteSchemaTo write the schema, set the value for the mode parameter to WriteSchema.

WriteXml(String)

DataSet 的目前資料寫入指定的檔案。Writes the current data for the DataSet to the specified file.

WriteXml(String, XmlWriteMode)

使用指定的 DataSet,寫入 XmlWriteMode 的目前資料 (並選擇性寫入結構描述) 至指定的檔案。Writes the current data, and optionally the schema, for the DataSet to the specified file using the specified XmlWriteMode. 若要寫入結構描述,請設定 mode 參數的值為 WriteSchemaTo write the schema, set the value for the mode parameter to WriteSchema.

WriteXml(TextWriter)

使用指定的 DataSet,寫入 TextWriter 的目前資料。Writes the current data for the DataSet using the specified TextWriter.

WriteXml(TextWriter, XmlWriteMode)

使用指定的 DataSetTextWriter,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。Writes the current data, and optionally the schema, for the DataSet using the specified TextWriter and XmlWriteMode. 若要寫入結構描述,請設定 mode 參數的值為 WriteSchemaTo write the schema, set the value for the mode parameter to WriteSchema.

WriteXml(XmlWriter)

DataSet 的目前資料寫入指定的 XmlWriterWrites the current data for the DataSet to the specified XmlWriter.

WriteXml(XmlWriter, XmlWriteMode)

使用指定的 DataSetXmlWriter,寫入 XmlWriteMode 的目前資料,並選擇性寫入結構描述。Writes the current data, and optionally the schema, for the DataSet using the specified XmlWriter and XmlWriteMode. 若要寫入結構描述,請設定 mode 參數的值為 WriteSchemaTo write the schema, set the value for the mode parameter to WriteSchema.

WriteXmlSchema(Stream)

DataSet 結構做為 XML 結構描述寫入指定的 Stream 物件。Writes the DataSet structure as an XML schema to the specified Stream object.

WriteXmlSchema(Stream, Converter<Type,String>)

DataSet 結構做為 XML 結構描述寫入指定的 Stream 物件。Writes the DataSet structure as an XML schema to the specified Stream object.

WriteXmlSchema(String)

DataSet 結構做為 XML 結構描述寫入檔案。Writes the DataSet structure as an XML schema to a file.

WriteXmlSchema(String, Converter<Type,String>)

DataSet 結構做為 XML 結構描述寫入檔案。Writes the DataSet structure as an XML schema to a file.

WriteXmlSchema(TextWriter)

DataSet 結構做為 XML 結構描述寫入指定的 TextWriter 物件。Writes the DataSet structure as an XML schema to the specified TextWriter object.

WriteXmlSchema(TextWriter, Converter<Type,String>)

DataSet 結構當做 XML 結構描述寫入至指定的 TextWriterWrites the DataSet structure as an XML schema to the specified TextWriter.

WriteXmlSchema(XmlWriter)

DataSet 結構做為 XML 結構描述寫入 XmlWriter 物件。Writes the DataSet structure as an XML schema to an XmlWriter object.

WriteXmlSchema(XmlWriter, Converter<Type,String>)

DataSet 結構當做 XML 結構描述寫入至指定的 XmlWriterWrites the DataSet structure as an XML schema to the specified XmlWriter.

事件

Disposed

加入事件處理常式來接聽 (Listen) 元件上的 Disposed 事件。Adds an event handler to listen to the Disposed event on the component.

(繼承來源 MarshalByValueComponent)
Initialized

發生於 DataSet 初始化之後。Occurs after the DataSet is initialized.

MergeFailed

當目標和來源 DataRow 有相同的主索引鍵值,且 EnforceConstraints 設定為 True 時發生。Occurs when a target and source DataRow have the same primary key value, and EnforceConstraints is set to true.

明確介面實作

IListSource.ContainsListCollection

如需這個成員的說明,請參閱 ContainsListCollectionFor a description of this member, see ContainsListCollection.

IListSource.GetList()

如需這個成員的說明,請參閱 GetList()For a description of this member, see GetList().

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

以序列化 DataSet 所需的資料,填入序列化資訊物件。Populates a serialization information object with the data needed to serialize the DataSet.

IXmlSerializable.GetSchema()

如需這個成員的說明,請參閱 GetSchema()For a description of this member, see GetSchema().

IXmlSerializable.ReadXml(XmlReader)

如需這個成員的說明,請參閱 ReadXml(XmlReader)For a description of this member, see ReadXml(XmlReader).

IXmlSerializable.WriteXml(XmlWriter)

如需這個成員的說明,請參閱 WriteXml(XmlWriter)For a description of this member, see WriteXml(XmlWriter).

適用於

執行緒安全性

這種類型對於多執行緒讀取作業而言是安全的。This type is safe for multithreaded read operations. 您必須同步處理任何寫入作業。You must synchronize any write operations.

另請參閱