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对象,请参阅数据集、 数据表和数据视图For 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对象,请参阅创建数据表For 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. 您可以将架构作为 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

获取或设置一个值,该值指示在尝试执行任何更新操作时是否遵循约束规则。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

获取一个值,该值指示是否已初始化 DataSetGets a value that indicates whether the DataSet is initialized.

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

获取或设置一个 XML 前缀,该前缀是 DataSet 的命名空间的别名。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

为远程处理期间使用的 SerializationFormat 获取或设置 DataSetGets 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

获取或设置 DataSetISiteGets 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()

开始初始化在窗体上使用或由另一个组件使用的 DataSetBegins 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 返回带有一个结果集的 DataTableReturns 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 占用的非托管资源,还可以另外再释放托管资源。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)

获取由 DataRowState 筛选的 DataSet 的副本,该副本包含上次加载以来或调用 AcceptChanges() 以来进行的所有更改。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,并使用字符串数组为 DataSet 中的表提供名称,从而用来自数据源的值填充 IDataReaderFills 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 的浅表副本。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)

使用指定的 Stream 将 XML 架构和数据读入 DataSetReads 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)

使用指定的 TextReader 将 XML 架构和数据读入 DataSetReads 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)

使用指定的 XmlReader 将 XML 架构和数据读入 DataSetReads 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 的名称的 String(如果有)。Returns 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)

使用指定的 DataSetStream 写当前数据。Writes the current data for the DataSet using the specified Stream.

WriteXml(Stream, XmlWriteMode) WriteXml(Stream, XmlWriteMode) WriteXml(Stream, XmlWriteMode) WriteXml(Stream, XmlWriteMode)

使用指定的 StreamXmlWriteMode 写入 DataSet 的当前数据和架构(可选)。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)

使用指定的 XmlWriteModeDataSet 的当前数据和架构(可选)写入指定的文件。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)

使用指定的 DataSetTextWriter 写当前数据。Writes the current data for the DataSet using the specified TextWriter.

WriteXml(TextWriter, XmlWriteMode) WriteXml(TextWriter, XmlWriteMode) WriteXml(TextWriter, XmlWriteMode) WriteXml(TextWriter, XmlWriteMode)

使用指定的 TextWriterXmlWriteMode 写入 DataSet 的当前数据和架构(可选)。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)

使用指定的 XmlWriterXmlWriteMode 写入 DataSet 的当前数据和架构(可选)。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)

将 XML 架构形式的 DataSet 结构写入文件。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>)

将 XML 架构形式的 DataSet 结构写入文件。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)

将 XML 架构形式的 DataSet 结构写入 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

添加事件处理程序以侦听组件上的 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 设置为真时发生。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.

另请参阅