DataAdapter DataAdapter DataAdapter DataAdapter Class

定义

表示一组 SQL 命令和一个数据库连接,它们用于填充 DataSet 和更新数据源。Represents a set of SQL commands and a database connection that are used to fill the DataSet and update the data source.

public ref class DataAdapter : System::ComponentModel::Component, System::Data::IDataAdapter
public class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
type DataAdapter = class
    inherit Component
    interface IDataAdapter
Public Class DataAdapter
Inherits Component
Implements IDataAdapter
继承
派生
实现

注解

用作数据源DataSet与数据源之间的桥梁以检索和保存数据。 DataAdapterThe DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. DataSet DataSet Update通过映射DataAdapter Fill提供此桥,这将更改中的数据以匹配数据源中的数据,并更改数据源中的数据以与中的数据相匹配。The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet.

如果要连接到 SQL Server 数据库,可以通过将及其关联SqlDataAdapter SqlCommand的和SqlConnection对象结合使用来提高整体性能。If you are connecting to a SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand and SqlConnection objects. 对于 OLE DB 支持的数据源,请将DataAdapter与其关联OleDbCommand的和OleDbConnection对象一起使用。For OLE DB-supported data sources, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects. 对于支持 ODBC 的数据源,请将DataAdapter与其关联OdbcCommand的和OdbcConnection对象一起使用。For ODBC-supported data sources, use the DataAdapter with its associated OdbcCommand and OdbcConnection objects. 对于 Oracle 数据库,请将DataAdapter与其关联OracleCommand的和OracleConnection对象一起使用。For Oracle databases, use the DataAdapter with its associated OracleCommand and OracleConnection objects.

创建的DataAdapter实例时,读/写属性将设置为初始值。When an instance of DataAdapter is created, the read/write properties are set to initial values. 有关这些值的列表,请参见DataAdapter构造函数。For a list of these values, see the DataAdapter constructor.

构造函数

DataAdapter() DataAdapter() DataAdapter() DataAdapter()

初始化 DataAdapter 类的新实例。Initializes a new instance of a DataAdapter class.

DataAdapter(DataAdapter) DataAdapter(DataAdapter) DataAdapter(DataAdapter) DataAdapter(DataAdapter)

从同一类型的现有对象中初始化 DataAdapter 类的新实例。Initializes a new instance of a DataAdapter class from an existing object of the same type.

属性

AcceptChangesDuringFill AcceptChangesDuringFill AcceptChangesDuringFill AcceptChangesDuringFill

获取或设置一个值,该值指示在任何 Fill 操作过程中,在将 AcceptChanges() 添加到 DataRow 之后是否在 DataTable 上调用它。Gets or sets a value indicating whether AcceptChanges() is called on a DataRow after it is added to the DataTable during any of the Fill operations.

AcceptChangesDuringUpdate AcceptChangesDuringUpdate AcceptChangesDuringUpdate AcceptChangesDuringUpdate

获取或设置在 AcceptChanges() 期间是否调用 Update(DataSet)Gets or sets whether AcceptChanges() is called during a Update(DataSet).

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(Inherited from Component)
ContinueUpdateOnError ContinueUpdateOnError ContinueUpdateOnError ContinueUpdateOnError

获取或设置一个值,该值指定在行更新过程中遇到错误时是否生成异常。Gets or sets a value that specifies whether to generate an exception when an error is encountered during a row update.

DesignMode DesignMode DesignMode DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
FillLoadOption FillLoadOption FillLoadOption FillLoadOption

获取或设置 LoadOption,后者确定适配器如何从 DataTable 中填充 DbDataReaderGets or sets the LoadOption that determines how the adapter fills the DataTable from the DbDataReader.

MissingMappingAction MissingMappingAction MissingMappingAction MissingMappingAction

确定传入数据没有匹配的表或列时需要执行的操作。Determines the action to take when incoming data does not have a matching table or column.

MissingSchemaAction MissingSchemaAction MissingSchemaAction MissingSchemaAction

确定现有 DataSet 架构与传入数据不匹配时需要执行的操作。Determines the action to take when existing DataSet schema does not match incoming data.

ReturnProviderSpecificTypes ReturnProviderSpecificTypes ReturnProviderSpecificTypes ReturnProviderSpecificTypes

获取或设置 Fill 方法是应当返回提供程序特定的值,还是返回公用的符合 CLS 的值。Gets or sets whether the Fill method should return provider-specific values or common CLS-compliant values.

Site Site Site Site

获取或设置 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
TableMappings TableMappings TableMappings TableMappings

获取一个集合,它提供源表和 DataTable 之间的主映射。Gets a collection that provides the master mapping between a source table and a DataTable.

方法

CloneInternals() CloneInternals() CloneInternals() CloneInternals()

创建此 DataAdapter 实例的一个副本。Creates a copy of this instance of DataAdapter.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
CreateTableMappings() CreateTableMappings() CreateTableMappings() CreateTableMappings()

创建一个新的 DataTableMappingCollectionCreates a new DataTableMappingCollection.

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

释放由 Component 使用的所有资源。Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 DataAdapter 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the DataAdapter and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Fill(DataSet) Fill(DataSet) Fill(DataSet) Fill(DataSet)

DataSet 中添加或刷新行以与数据源中的行匹配。Adds or refreshes rows in the DataSet to match those in the data source.

Fill(DataSet, String, IDataReader, Int32, Int32) Fill(DataSet, String, IDataReader, Int32, Int32) Fill(DataSet, String, IDataReader, Int32, Int32) Fill(DataSet, String, IDataReader, Int32, Int32)

DataSet 的指定范围中添加或刷新行以匹配使用 DataSetDataTable 名称的数据源中的行。Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.

Fill(DataTable, IDataReader) Fill(DataTable, IDataReader) Fill(DataTable, IDataReader) Fill(DataTable, IDataReader)

DataTable 中添加或刷新行以与使用 DataTable 名称和指定的 IDataReader 的数据源中的行匹配。Adds or refreshes rows in the DataTable to match those in the data source using the DataTable name and the specified IDataReader.

Fill(DataTable[], IDataReader, Int32, Int32) Fill(DataTable[], IDataReader, Int32, Int32) Fill(DataTable[], IDataReader, Int32, Int32) Fill(DataTable[], IDataReader, Int32, Int32)

DataTable 对象集合的指定范围中添加或刷新行以与数据源中的行匹配。Adds or refreshes rows in a specified range in the collection of DataTable objects to match those in the data source.

FillSchema(DataSet, SchemaType) FillSchema(DataSet, SchemaType) FillSchema(DataSet, SchemaType) FillSchema(DataSet, SchemaType)

DataTable 添加到指定的 DataSet 中,并根据指定的 SchemaType 配置架构以匹配数据源中的架构。Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.

FillSchema(DataSet, SchemaType, String, IDataReader) FillSchema(DataSet, SchemaType, String, IDataReader) FillSchema(DataSet, SchemaType, String, IDataReader) FillSchema(DataSet, SchemaType, String, IDataReader)

向指定的 DataTable 添加一个 DataSetAdds a DataTable to the specified DataSet.

FillSchema(DataTable, SchemaType, IDataReader) FillSchema(DataTable, SchemaType, IDataReader) FillSchema(DataTable, SchemaType, IDataReader) FillSchema(DataTable, SchemaType, IDataReader)

向指定的 DataTable 添加一个 DataSetAdds a DataTable to the specified DataSet.

GetFillParameters() GetFillParameters() GetFillParameters() GetFillParameters()

获取当执行 SQL SELECT 语句时由用户设置的参数。Gets the parameters set by the user when executing an SQL SELECT statement.

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

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
HasTableMappings() HasTableMappings() HasTableMappings() HasTableMappings()

指示是否已创建了一个 DataTableMappingCollectionIndicates whether a DataTableMappingCollection has been created.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnFillError(FillErrorEventArgs) OnFillError(FillErrorEventArgs) OnFillError(FillErrorEventArgs) OnFillError(FillErrorEventArgs)

Fill 过程中出现错误时调用。Invoked when an error occurs during a Fill.

ResetFillLoadOption() ResetFillLoadOption() ResetFillLoadOption() ResetFillLoadOption()

FillLoadOption 重置为默认状态,并使 Fill(DataSet) 接受 AcceptChangesDuringFillResets FillLoadOption to its default state and causes Fill(DataSet) to honor AcceptChangesDuringFill.

ShouldSerializeAcceptChangesDuringFill() ShouldSerializeAcceptChangesDuringFill() ShouldSerializeAcceptChangesDuringFill() ShouldSerializeAcceptChangesDuringFill()

确定是否应保持 AcceptChangesDuringFill 属性。Determines whether the AcceptChangesDuringFill property should be persisted.

ShouldSerializeFillLoadOption() ShouldSerializeFillLoadOption() ShouldSerializeFillLoadOption() ShouldSerializeFillLoadOption()

确定是否应保持 FillLoadOption 属性。Determines whether the FillLoadOption property should be persisted.

ShouldSerializeTableMappings() ShouldSerializeTableMappings() ShouldSerializeTableMappings() ShouldSerializeTableMappings()

确定一个或多个 DataTableMapping 对象是否存在,并且它们是否应该是持久的。Determines whether one or more DataTableMapping objects exist and they 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 Component)
Update(DataSet) Update(DataSet) Update(DataSet) Update(DataSet)

从名为“Table”的 DataSet 为指定的 DataTable 中每个已插入、已更新或已删除的行调用相应的 INSERT、UPDATE 或 DELETE 语句。Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet from a DataTable named "Table."

事件

Disposed Disposed Disposed Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)
FillError FillError FillError FillError

在填充操作过程中出现错误时返回。Returned when an error occurs during a fill operation.

显式界面实现

IDataAdapter.TableMappings IDataAdapter.TableMappings IDataAdapter.TableMappings IDataAdapter.TableMappings

指示如何将源表映射到数据集表。Indicates how a source table is mapped to a dataset table.

适用于

另请参阅