DataAdapter 类

定义

表示用于填充 DataSet 和更新数据源的一组 SQL 命令和一个数据库连接。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 ref class DataAdapter abstract : System::ComponentModel::Component, System::Data::IDataAdapter
public class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
public abstract class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
type DataAdapter = class
    inherit Component
    interface IDataAdapter
Public Class DataAdapter
Inherits Component
Implements IDataAdapter
Public MustInherit Class DataAdapter
Inherits Component
Implements IDataAdapter
继承
派生
实现

注解

DataAdapter 充当用于检索和保存数据的 DataSet 与数据源之间的桥梁。The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. DataAdapter 通过映射 Fill来提供此桥,这将更改 DataSet 中的数据以匹配数据源中的数据,Update并将更改数据源中的数据,使其与 DataSet中的数据相匹配。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 连同关联的 SqlCommandSqlConnection 对象,提高整体性能。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 与其关联的 OleDbCommandOleDbConnection 对象结合使用。For OLE DB-supported data sources, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects. 对于支持 ODBC 的数据源,请将 DataAdapter 与其关联的 OdbcCommandOdbcConnection 对象一起使用。For ODBC-supported data sources, use the DataAdapter with its associated OdbcCommand and OdbcConnection objects. 对于 Oracle 数据库,将 DataAdapter 与其关联的 OracleCommandOracleConnection 对象一起使用。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 类的新实例。Initializes a new instance of a DataAdapter class.

DataAdapter(DataAdapter)

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

属性

AcceptChangesDuringFill

获取或设置一个值,该值指示在任何 FillAcceptChanges()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

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

CanRaiseEvents

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

(继承自 Component)
Container

获取包含 IContainerComponentGets the IContainer that contains the Component.

(继承自 Component)
ContinueUpdateOnError

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

DesignMode

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

(继承自 Component)
Events

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

(继承自 Component)
FillLoadOption

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

MissingMappingAction

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

MissingSchemaAction

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

ReturnProviderSpecificTypes

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

Site

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

(继承自 Component)
TableMappings

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

方法

CloneInternals()

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

CreateObjRef(Type)

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

(继承自 MarshalByRefObject)
CreateTableMappings()

创建一个新的 DataTableMappingCollectionCreates a new DataTableMappingCollection.

Dispose()

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

(继承自 Component)
Dispose(Boolean)

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

Equals(Object)

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

(继承自 Object)
Fill(DataSet)

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

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)

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)

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)

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)

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

FillSchema(DataTable, SchemaType, IDataReader)

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

GetFillParameters()

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

GetHashCode()

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

(继承自 Object)
GetLifetimeService()

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

(继承自 MarshalByRefObject)
GetService(Type)

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

(继承自 Component)
GetType()

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

(继承自 Object)
HasTableMappings()

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

InitializeLifetimeService()

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

(继承自 MarshalByRefObject)
MemberwiseClone()

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

(继承自 Object)
MemberwiseClone(Boolean)

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

(继承自 MarshalByRefObject)
OnFillError(FillErrorEventArgs)

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

ResetFillLoadOption()

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

ShouldSerializeAcceptChangesDuringFill()

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

ShouldSerializeFillLoadOption()

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

ShouldSerializeTableMappings()

确定一个或多个 DataTableMapping 对象是否存在,并且它们是否应该是持久的。Determines whether one or more DataTableMapping objects exist and they should be persisted.

ToString()

返回包含 String 的名称的 Component(如果有)。Returns a String containing the name of the Component, if any. 不应重写此方法。This method should not be overridden.

(继承自 Component)
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

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

(继承自 Component)
FillError

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

显式接口实现

IDataAdapter.TableMappings

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

适用于

另请参阅