DbDataAdapter Class

定义

帮助实现 IDbDataAdapter 接口。 Aids implementation of the IDbDataAdapter interface. DbDataAdapter 的继承类实现了一组功能以提供强类型,但是继承了完全实现 DataAdapter 所需的大部分功能。 Inheritors of DbDataAdapter implement a set of functions to provide strong typing, but inherit most of the functionality needed to fully implement a DataAdapter.

public abstract class DbDataAdapter : System.Data.Common.DataAdapter, ICloneable, System.Data.IDbDataAdapter
继承
派生
实现

注解

DbDataAdapter类继承自DataAdapter类,并实现IDbDataAdapter接口。The DbDataAdapter class inherits from the DataAdapter class and implements the IDbDataAdapter interface. 它可帮助实现的类DataAdapter设计用于关系数据库。It helps a class implement a DataAdapter designed for use with a relational database.

应用程序不会创建的实例DbDataAdapter类直接,但创建从其继承的类的实例。An application does not create an instance of the DbDataAdapter class directly, but creates an instance of a class that inherits from it.

继承的类DbDataAdapter必须实现继承的成员,且通常定义其他成员来添加特定于提供程序的功能。Classes that inherit DbDataAdapter must implement the inherited members, and typically define additional members to add provider-specific functionality. 例如,DbDataAdapter类定义SelectCommand属性,并DbDataAdapter类定义的八个重载Fill方法。For example, the DbDataAdapter class defines the SelectCommand property, and the DbDataAdapter class defines eight overloads of the Fill method. 依次OleDbDataAdapter类继承Fill方法,并且还定义了两个重载的Fill采取 ADO 记录集对象作为参数。In turn, the OleDbDataAdapter class inherits the Fill method, and also defines two additional overloads of Fill that take an ADO Recordset object as a parameter.

继承者说明

继承自DbDataAdapter类中,我们建议你实现以下构造函数:

说明
PrvDataAdapter() 的新实例初始化PrvDataAdapter 类。
PrvDataAdapter (Prv命令selectCommand) 初始化的新实例PrvDataAdapter 类用指定的 SQL SELECT 语句。
PrvDataAdapter (字符串selectCommandText,字符串selectConnectionString) 初始化的新实例PrvDataAdapter 类使用的 SQL SELECT 语句和连接字符串。
PrvDataAdapter (字符串selectCommandTextPrv连接selectConnection) 初始化新实例PrvDataAdapter 类的一个 SQL SELECT 语句和一个Prv连接对象。
若要将升级.NET Framework 数据提供程序之间的一致性,应命名窗体中的继承类PrvDataAdapter,其中Prv是提供给特定的.NET 中的所有类的统一前缀Framework 数据提供程序命名空间。例如,"Sql"是前缀SqlDataAdapter类中System.Data.SqlClient命名空间。

When you inherit from the DbDataAdapter class, we recommend that you implement the following constructors:

Item Description
PrvDataAdapter() Initializes a new instance of the PrvDataAdapter class.
PrvDataAdapter(PrvCommand selectCommand) Initializes a new instance of the PrvDataAdapter class with the specified SQL SELECT statement.
PrvDataAdapter(string selectCommandText, string selectConnectionString) Initializes a new instance of the PrvDataAdapter class with an SQL SELECT statement and a connection string.
PrvDataAdapter(string selectCommandText, PrvConnection selectConnection) Initializes a new instance of the PrvDataAdapter class with an SQL SELECT statement and a PrvConnection object.
To promote consistency among .NET Framework data providers, you should name the inheriting class in the form PrvDataAdapter, where Prv is the uniform prefix given to all classes in a specific .NET Framework data provider namespace. For example, "Sql" is the prefix of the SqlDataAdapter class in the System.Data.SqlClient namespace.

构造函数

DbDataAdapter()

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

DbDataAdapter(DbDataAdapter)

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

字段

DefaultSourceTableName

DataAdapter 对象用于表映射的默认名称。 The default name used by the DataAdapter object for table mappings.

属性

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.

(Inherited from DataAdapter)
AcceptChangesDuringUpdate

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

(Inherited from DataAdapter)
CanRaiseEvents

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

(Inherited from Component)
Container

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

(Inherited from Component)
ContinueUpdateOnError

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

(Inherited from DataAdapter)
DeleteCommand

获取或设置用于从数据集中删除记录的命令。 Gets or sets a command for deleting records from the data set.

DesignMode

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

(Inherited from Component)
Events

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

(Inherited from Component)
FillCommandBehavior

获取或设置用于填充数据适配器的命令的行为。 Gets or sets the behavior of the command used to fill the data adapter.

FillLoadOption

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

(Inherited from DataAdapter)
IDataAdapter.TableMappings

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

(Inherited from DataAdapter)
InsertCommand

获取或设置用于将新记录插入到数据源中的命令。 Gets or sets a command used to insert new records into the data source.

MissingMappingAction

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

(Inherited from DataAdapter)
MissingSchemaAction

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

(Inherited from DataAdapter)
ReturnProviderSpecificTypes

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

(Inherited from DataAdapter)
SelectCommand

获取或设置用于在数据源中选择记录的命令。 Gets or sets a command used to select records in the data source.

Site

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

(Inherited from Component)
TableMappings

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

(Inherited from DataAdapter)
UpdateBatchSize

获取或设置一个值,该值启用或禁用批处理支持,并且指定可在一次批处理中执行的命令的数量。 Gets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch.

UpdateCommand

获取或设置用于更新数据源中的记录的命令。 Gets or sets a command used to update records in the data source.

方法

AddToBatch(IDbCommand)

向当前批处理添加 IDbCommand Adds a IDbCommand to the current batch.

ClearBatch()

从批处理中移除所有 IDbCommand 对象。 Removes all IDbCommand objects from the batch.

CloneInternals()

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

(Inherited from DataAdapter)
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)
CreateRowUpdatedEvent(DataRow, IDbCommand, StatementType, DataTableMapping)

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

CreateRowUpdatingEvent(DataRow, IDbCommand, StatementType, DataTableMapping)

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

CreateTableMappings()

创建一个新的 DataTableMappingCollection Creates a new DataTableMappingCollection.

(Inherited from DataAdapter)
Dispose()

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

(Inherited from Component)
Dispose(Boolean)

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

Equals(Object)

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

(Inherited from Object)
ExecuteBatch()

执行当前批处理。 Executes the current batch.

Fill(DataSet)

DataSet 中添加或刷新行。 Adds or refreshes rows in the DataSet.

Fill(DataSet, Int32, Int32, String)

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(DataSet, Int32, Int32, String, IDbCommand, CommandBehavior)

使用 DataSet 和源表名称、命令字符串以及命令行为,在 DataSet 的指定范围中添加或刷新某些行以使它们与数据源中对应的行相一致。 Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and source table names, command string, and command behavior.

Fill(DataSet, String)

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

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

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

Fill(DataTable, IDataReader)
Fill(DataTable, IDbCommand, CommandBehavior)

DataTable 中添加或刷新行,以与使用指定的 DataTableIDbCommandCommandBehavior 的数据源中的行匹配。 Adds or refreshes rows in a DataTable to match those in the data source using the specified DataTable, IDbCommand and CommandBehavior.

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.

(Inherited from DataAdapter)
Fill(DataTable[], Int32, Int32, IDbCommand, CommandBehavior)

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

DataTable 中添加或刷新行,以与从指定的记录开始一直检索到指定的最大数目的记录的数据源中的行匹配。 Adds or refreshes rows in a DataTable to match those in the data source starting at the specified record and retrieving up to the specified maximum number of records.

FillSchema(DataSet, SchemaType)

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

FillSchema(DataSet, SchemaType, IDbCommand, String, CommandBehavior)

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)

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

FillSchema(DataSet, SchemaType, String, IDataReader)

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

(Inherited from DataAdapter)
FillSchema(DataTable, SchemaType)

根据指定的 DataTable 配置指定 SchemaType 的架构。 Configures the schema of the specified DataTable based on the specified SchemaType.

FillSchema(DataTable, SchemaType, IDataReader)

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

(Inherited from DataAdapter)
FillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior)

根据指定的 DataTable、命令字符串以及 SchemaType 值配置指定 CommandBehavior 的架构。 Configures the schema of the specified DataTable based on the specified SchemaType, command string, and CommandBehavior values.

GetBatchedParameter(Int32, Int32)

从当前批处理中的其中一个命令返回一个 IDataParameter Returns a IDataParameter from one of the commands in the current batch.

GetBatchedRecordsAffected(Int32, Int32, Exception)

返回与较大的批处理更新内的单次更新尝试有关的信息。 Returns information about an individual update attempt within a larger batched update.

GetFillParameters()

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

GetHashCode()

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

(Inherited from Object)
GetLifetimeService()

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

(Inherited from MarshalByRefObject)
GetService(Type)

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

(Inherited from Component)
GetType()

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

(Inherited from Object)
HasTableMappings()

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

(Inherited from DataAdapter)
InitializeBatching()

初始化 DbDataAdapter 的批处理。 Initializes batching for the DbDataAdapter.

InitializeLifetimeService()

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

(Inherited from MarshalByRefObject)
MemberwiseClone()

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

(Inherited from Object)
MemberwiseClone(Boolean)

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

(Inherited from MarshalByRefObject)
OnFillError(FillErrorEventArgs)
OnRowUpdated(RowUpdatedEventArgs)

引发 .NET Framework 数据提供程序的 RowUpdated 事件。 Raises the RowUpdated event of a .NET Framework data provider.

OnRowUpdating(RowUpdatingEventArgs)

引发 .NET Framework 数据提供程序的 RowUpdating 事件。 Raises the RowUpdating event of a .NET Framework data provider.

ResetFillLoadOption()

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

(Inherited from DataAdapter)
ShouldSerializeAcceptChangesDuringFill()

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

(Inherited from DataAdapter)
ShouldSerializeFillLoadOption()

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

(Inherited from DataAdapter)
ShouldSerializeTableMappings()

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

(Inherited from DataAdapter)
TerminateBatching()

结束 DbDataAdapter 的批处理。 Ends batching for the DbDataAdapter.

ToString()

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

(Inherited from Component)
Update(DataRow[])

通过为 DataSet 中的指定数组中的每个已插入、已更新或已删除的行执行相应的 INSERT、UPDATE 或 DELETE 语句来更新数据库中的值。 Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array in the DataSet.

Update(DataRow[], DataTableMapping)

通过为指定的 DataSet 对象数组中的每个已插入、已更新或已删除的行执行相应的 INSERT、UPDATE 或 DELETE 语句来更新数据库中的值。 Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array of DataSet objects.

Update(DataSet)

通过为指定的 DataSet 中的每个已插入、已更新或已删除的行执行相应的 INSERT、UPDATE 或 DELETE 语句来更新数据库中的值。 Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet.

Update(DataSet, String)

通过为具有指定名称 DataSetDataTable 中的每个已插入、已更新或已删除的行执行相应的 INSERT、UPDATE 或 DELETE 语句来更新数据库中的值。 Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet with the specified DataTable name.

Update(DataTable)

通过为指定的 DataTable 中的每个已插入、已更新或已删除的行执行相应的 INSERT、UPDATE 或 DELETE 语句来更新数据库中的值。 Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataTable.

事件

Disposed

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

(Inherited from Component)
FillError

显式界面实现

ICloneable.Clone()

创建作为当前实例副本的新对象。 Creates a new object that is a copy of the current instance.

IDbDataAdapter.DeleteCommand

获取或设置用于从数据集中删除记录的 SQL 语句。 Gets or sets an SQL statement for deleting records from the data set.

IDbDataAdapter.InsertCommand

获取或设置用于将新记录插入到数据源中的 SQL 语句。 Gets or sets an SQL statement used to insert new records into the data source.

IDbDataAdapter.SelectCommand

获取或设置用于在数据源中选择记录的 SQL 语句。 Gets or sets an SQL statement used to select records in the data source.

IDbDataAdapter.UpdateCommand

获取或设置用于更新数据源中的记录的 SQL 语句。 Gets or sets an SQL statement used to update records in the data source.

适用于