DataSet DataSet DataSet DataSet Class

定義

代表資料的記憶體中快取。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
繼承
屬性
實作

範例

下列範例包含數種方法結合,建立並填入DataSetNorthwind資料庫。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 SqlCommand = 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 DataSet = 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 SqlDataAdapter = _
                New SqlDataAdapter()
            productsAdapter.TableMappings.Add("Table", "Products")

            Dim productsCommand As SqlCommand = 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 DataRelation = New _
               System.Data.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. DataSet組成的集合DataTable物件,您可以相互關聯與DataRelation物件。The DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects. 您也可以強制執行中的資料完整性DataSet利用UniqueConstraintForeignKeyConstraint物件。You can also enforce data integrity in the DataSet by using the UniqueConstraint and ForeignKeyConstraint objects. 如需有關使用的詳細資訊DataSet物件,請參閱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. 中所包含的資料表DataTableCollection經由Tables屬性。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.

ADataSet可以讀取和寫入資料和結構描述為 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. 您可以使用的 XML 結構描述儲存結構描述WriteXmlSchema方法,,和結構描述和資料可以儲存使用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. 建置並填滿每DataTableDataSet從資料來源使用的資料與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. 叫用GetChanges方法用來建立第二個DataSet該功能的資料變更。Invoke the GetChanges method to create a second DataSet that features only the changes to the data.

  4. 呼叫Update方法DataAdapter,將第二個DataSet做為引數。Call the Update method of the DataAdapter, passing the second DataSet as an argument.

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

  6. 叫用AcceptChangesDataSetInvoke the AcceptChanges on the DataSet. 或者,叫用RejectChanges取消所做的變更。Alternatively, invoke RejectChanges to cancel the changes.

注意

DataSetDataTable物件會繼承自MarshalByValueComponent,並支援ISerializable針對遠端執行功能的介面。The 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不會完成記憶體回收行程,因為完成項已隱藏在DataSetClasses 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() DataSet() DataSet()

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

DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext) DataSet(SerializationInfo, StreamingContext) 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(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean) DataSet(SerializationInfo, StreamingContext, Boolean)

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

DataSet(String) DataSet(String) DataSet(String) DataSet(String)

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

屬性

CaseSensitive CaseSensitive CaseSensitive CaseSensitive

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

Container Container Container Container

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

(Inherited from MarshalByValueComponent)
DataSetName DataSetName DataSetName DataSetName

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

DefaultViewManager DefaultViewManager DefaultViewManager 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 DesignMode DesignMode DesignMode

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

(Inherited from MarshalByValueComponent)
EnforceConstraints EnforceConstraints EnforceConstraints EnforceConstraints

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

Events Events Events Events

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

(Inherited from MarshalByValueComponent)
ExtendedProperties ExtendedProperties ExtendedProperties ExtendedProperties

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

HasErrors HasErrors HasErrors HasErrors

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

IsInitialized IsInitialized IsInitialized IsInitialized

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

Locale Locale Locale Locale

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

Namespace Namespace Namespace Namespace

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

Prefix Prefix Prefix Prefix

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

Relations Relations Relations Relations

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

RemotingFormat RemotingFormat RemotingFormat RemotingFormat

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

SchemaSerializationMode SchemaSerializationMode SchemaSerializationMode SchemaSerializationMode

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

Site Site Site Site

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

Tables Tables Tables Tables

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

方法

AcceptChanges() AcceptChanges() AcceptChanges() AcceptChanges()

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

BeginInit() BeginInit() BeginInit() 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() Clear() Clear() Clear()

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

Clone() Clone() Clone() Clone()

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

Copy() Copy() Copy() Copy()

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

CreateDataReader() CreateDataReader() CreateDataReader() 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[]) CreateDataReader(DataTable[]) CreateDataReader(DataTable[]) CreateDataReader(DataTable[])

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

DetermineSchemaSerializationMode(SerializationInfo, StreamingContext) DetermineSchemaSerializationMode(SerializationInfo, StreamingContext) DetermineSchemaSerializationMode(SerializationInfo, StreamingContext) DetermineSchemaSerializationMode(SerializationInfo, StreamingContext)

判斷 SchemaSerializationModeDataSetDetermines the SchemaSerializationMode for a DataSet.

DetermineSchemaSerializationMode(XmlReader) DetermineSchemaSerializationMode(XmlReader) DetermineSchemaSerializationMode(XmlReader) DetermineSchemaSerializationMode(XmlReader)

判斷 SchemaSerializationModeDataSetDetermines the SchemaSerializationMode for a DataSet.

Dispose() Dispose() Dispose() Dispose()

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

(Inherited from MarshalByValueComponent)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

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

(Inherited from MarshalByValueComponent)
EndInit() EndInit() EndInit() 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) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetChanges() GetChanges() GetChanges() 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) GetChanges(DataRowState) GetChanges(DataRowState) 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) GetDataSetSchema(XmlSchemaSet) GetDataSetSchema(XmlSchemaSet) GetDataSetSchema(XmlSchemaSet)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

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

GetSchemaSerializable() GetSchemaSerializable() GetSchemaSerializable() GetSchemaSerializable()

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

GetSerializationData(SerializationInfo, StreamingContext) GetSerializationData(SerializationInfo, StreamingContext) GetSerializationData(SerializationInfo, StreamingContext) GetSerializationData(SerializationInfo, StreamingContext)

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

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

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

(Inherited from MarshalByValueComponent)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
GetXml() GetXml() GetXml() GetXml()

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

GetXmlSchema() GetXmlSchema() GetXmlSchema() GetXmlSchema()

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

HasChanges() HasChanges() HasChanges() HasChanges()

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

HasChanges(DataRowState) HasChanges(DataRowState) HasChanges(DataRowState) 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[]) InferXmlSchema(Stream, String[]) InferXmlSchema(Stream, String[]) InferXmlSchema(Stream, String[])

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

InferXmlSchema(String, String[]) InferXmlSchema(String, String[]) InferXmlSchema(String, String[]) InferXmlSchema(String, String[])

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

InferXmlSchema(TextReader, String[]) InferXmlSchema(TextReader, String[]) InferXmlSchema(TextReader, String[]) InferXmlSchema(TextReader, String[])

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

InferXmlSchema(XmlReader, String[]) InferXmlSchema(XmlReader, String[]) InferXmlSchema(XmlReader, String[]) InferXmlSchema(XmlReader, String[])

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

InitializeDerivedDataSet() InitializeDerivedDataSet() InitializeDerivedDataSet() InitializeDerivedDataSet()

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

IsBinarySerialized(SerializationInfo, StreamingContext) IsBinarySerialized(SerializationInfo, StreamingContext) IsBinarySerialized(SerializationInfo, StreamingContext) IsBinarySerialized(SerializationInfo, StreamingContext)

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

Load(IDataReader, LoadOption, DataTable[]) Load(IDataReader, LoadOption, DataTable[]) Load(IDataReader, LoadOption, DataTable[]) 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[]) Load(IDataReader, LoadOption, FillErrorEventHandler, DataTable[]) Load(IDataReader, LoadOption, FillErrorEventHandler, DataTable[]) 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[]) Load(IDataReader, LoadOption, String[]) Load(IDataReader, LoadOption, String[]) 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() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Merge(DataRow[]) Merge(DataRow[]) Merge(DataRow[]) Merge(DataRow[])

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

Merge(DataRow[], Boolean, MissingSchemaAction) Merge(DataRow[], Boolean, MissingSchemaAction) Merge(DataRow[], Boolean, MissingSchemaAction) 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) Merge(DataSet) Merge(DataSet) Merge(DataSet)

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

Merge(DataSet, Boolean) Merge(DataSet, Boolean) Merge(DataSet, Boolean) 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) Merge(DataSet, Boolean, MissingSchemaAction) Merge(DataSet, Boolean, MissingSchemaAction) 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) Merge(DataTable) Merge(DataTable) Merge(DataTable)

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

Merge(DataTable, Boolean, MissingSchemaAction) Merge(DataTable, Boolean, MissingSchemaAction) Merge(DataTable, Boolean, MissingSchemaAction) 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) OnPropertyChanging(PropertyChangedEventArgs) OnPropertyChanging(PropertyChangedEventArgs)

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

OnRemoveRelation(DataRelation) OnRemoveRelation(DataRelation) OnRemoveRelation(DataRelation) OnRemoveRelation(DataRelation)

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

OnRemoveTable(DataTable) OnRemoveTable(DataTable) OnRemoveTable(DataTable) OnRemoveTable(DataTable)

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

RaisePropertyChanging(String) RaisePropertyChanging(String) RaisePropertyChanging(String) RaisePropertyChanging(String)

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

ReadXml(Stream) ReadXml(Stream) ReadXml(Stream) ReadXml(Stream)

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

ReadXml(Stream, XmlReadMode) ReadXml(Stream, XmlReadMode) ReadXml(Stream, XmlReadMode) ReadXml(Stream, XmlReadMode)

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

ReadXml(String) ReadXml(String) ReadXml(String) ReadXml(String)

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

ReadXml(String, XmlReadMode) ReadXml(String, XmlReadMode) ReadXml(String, XmlReadMode) ReadXml(String, XmlReadMode)

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

ReadXml(TextReader) ReadXml(TextReader) ReadXml(TextReader) ReadXml(TextReader)

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

ReadXml(TextReader, XmlReadMode) ReadXml(TextReader, XmlReadMode) ReadXml(TextReader, XmlReadMode) ReadXml(TextReader, XmlReadMode)

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

ReadXml(XmlReader) ReadXml(XmlReader) ReadXml(XmlReader) ReadXml(XmlReader)

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

ReadXml(XmlReader, XmlReadMode) ReadXml(XmlReader, XmlReadMode) ReadXml(XmlReader, XmlReadMode) ReadXml(XmlReader, XmlReadMode)

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

ReadXmlSchema(Stream) ReadXmlSchema(Stream) ReadXmlSchema(Stream) ReadXmlSchema(Stream)

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

ReadXmlSchema(String) ReadXmlSchema(String) ReadXmlSchema(String) ReadXmlSchema(String)

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

ReadXmlSchema(TextReader) ReadXmlSchema(TextReader) ReadXmlSchema(TextReader) ReadXmlSchema(TextReader)

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

ReadXmlSchema(XmlReader) ReadXmlSchema(XmlReader) ReadXmlSchema(XmlReader) ReadXmlSchema(XmlReader)

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

ReadXmlSerializable(XmlReader) ReadXmlSerializable(XmlReader) ReadXmlSerializable(XmlReader) ReadXmlSerializable(XmlReader)

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

RejectChanges() RejectChanges() RejectChanges() 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() Reset() Reset() 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() ShouldSerializeRelations() ShouldSerializeRelations() ShouldSerializeRelations()

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

ShouldSerializeTables() ShouldSerializeTables() ShouldSerializeTables() ShouldSerializeTables()

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

ToString() ToString() ToString() ToString()

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

(Inherited from MarshalByValueComponent)
WriteXml(Stream) WriteXml(Stream) WriteXml(Stream) WriteXml(Stream)

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

WriteXml(Stream, XmlWriteMode) WriteXml(Stream, XmlWriteMode) WriteXml(Stream, XmlWriteMode) 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) WriteXml(String) WriteXml(String) WriteXml(String)

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

WriteXml(String, XmlWriteMode) WriteXml(String, XmlWriteMode) WriteXml(String, XmlWriteMode) 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) WriteXml(TextWriter) WriteXml(TextWriter) WriteXml(TextWriter)

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

WriteXml(TextWriter, XmlWriteMode) WriteXml(TextWriter, XmlWriteMode) WriteXml(TextWriter, XmlWriteMode) 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) WriteXml(XmlWriter) WriteXml(XmlWriter) WriteXml(XmlWriter)

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

WriteXml(XmlWriter, XmlWriteMode) WriteXml(XmlWriter, XmlWriteMode) WriteXml(XmlWriter, XmlWriteMode) 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) WriteXmlSchema(Stream) WriteXmlSchema(Stream) WriteXmlSchema(Stream)

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

WriteXmlSchema(Stream, Converter<Type,String>) WriteXmlSchema(Stream, Converter<Type,String>) WriteXmlSchema(Stream, Converter<Type,String>) WriteXmlSchema(Stream, Converter<Type,String>)

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

WriteXmlSchema(String) WriteXmlSchema(String) WriteXmlSchema(String) WriteXmlSchema(String)

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

WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>) WriteXmlSchema(String, Converter<Type,String>)

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

WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter) WriteXmlSchema(TextWriter)

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

WriteXmlSchema(TextWriter, Converter<Type,String>) WriteXmlSchema(TextWriter, Converter<Type,String>) WriteXmlSchema(TextWriter, Converter<Type,String>) WriteXmlSchema(TextWriter, Converter<Type,String>)

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

WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter) WriteXmlSchema(XmlWriter)

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

WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,String>) WriteXmlSchema(XmlWriter, Converter<Type,String>)

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

事件

Disposed Disposed Disposed Disposed

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

(Inherited from MarshalByValueComponent)
Initialized Initialized Initialized Initialized

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

MergeFailed MergeFailed MergeFailed 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 IListSource.ContainsListCollection IListSource.ContainsListCollection IListSource.ContainsListCollection

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

IListSource.GetList() IListSource.GetList() IListSource.GetList() IListSource.GetList()

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

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

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

IXmlSerializable.GetSchema() IXmlSerializable.GetSchema() IXmlSerializable.GetSchema() IXmlSerializable.GetSchema()

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

IXmlSerializable.ReadXml(XmlReader) IXmlSerializable.ReadXml(XmlReader) IXmlSerializable.ReadXml(XmlReader) IXmlSerializable.ReadXml(XmlReader)

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

IXmlSerializable.WriteXml(XmlWriter) IXmlSerializable.WriteXml(XmlWriter) IXmlSerializable.WriteXml(XmlWriter) 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.

另請參閱