DbCommandBuilder 类

定义

自动生成用于协调 DataSet 的更改与关联数据库的单表命令。Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated database. 这是一个只能被继承的抽象类。This is an abstract class that can only be inherited.

public ref class DbCommandBuilder abstract : System::ComponentModel::Component
public abstract class DbCommandBuilder : System.ComponentModel.Component
type DbCommandBuilder = class
    inherit Component
Public MustInherit Class DbCommandBuilder
Inherits Component
继承
派生

注解

DbCommandBuilder提供类是为了方便提供程序编写器创建自己的命令生成器。The DbCommandBuilder class is provided for the convenience of provider writers creating their own command builders. 通过继承此类,开发人员可以在自己的代码中实现特定于提供程序的行为。By inheriting from this class, developers can implement provider specific behavior in their own code.

DbDataAdapter 会自动生成将对的更改 DataSet 与关联的数据源进行协调所需的 SQL 语句。The DbDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a DataSet with the associated data source. 但是,如果设置了的属性,则可以创建一个 DbCommandBuilder 对象来自动为单表更新生成 SQL 语句 SelectCommand DbDataAdapterHowever, you can create a DbCommandBuilder object to automatically generate SQL statements for single-table updates if you set the SelectCommand property of the DbDataAdapter. 然后,将生成未设置的任何其他 SQL 语句 DbCommandBuilderThen, any additional SQL statements that you do not set are generated by the DbCommandBuilder.

DbCommandBuilder RowUpdating 只要设置属性,就会将自身注册为事件侦听器 DataAdapterThe DbCommandBuilder registers itself as a listener for RowUpdating events whenever you set the DataAdapter property. 一次只能将一个 DbDataAdapterDbCommandBuilder 对象彼此关联。You can only associate one DbDataAdapter or DbCommandBuilder object with each other at one time.

若要生成 INSERT、UPDATE 或 DELETE 语句,请 DbCommandBuilder 使用 SelectCommand 属性来自动检索所需的元数据集。To generate INSERT, UPDATE, or DELETE statements, the DbCommandBuilder uses the SelectCommand property to retrieve a required set of metadata automatically. 如果在 SelectCommand 检索元数据后更改, (例如,在第一次更新) 后,应调用 RefreshSchema 方法来更新元数据。If you change the SelectCommand after the metadata has been retrieved (for example, after the first update), you should call the RefreshSchema method to update the metadata.

SelectCommand 还必须至少返回一个主键或唯一列。The SelectCommand must also return at least one primary key or unique column. 如果不存在, InvalidOperationException 则会生成异常,并且不生成命令。If none exist, an InvalidOperationException exception is generated, and the commands are not generated.

DbCommandBuilder还使用引用的 ConnectionCommandTimeoutTransaction 属性 SelectCommandThe DbCommandBuilder also uses the Connection, CommandTimeout, and Transaction properties referenced by the SelectCommand. RefreshSchema如果修改了这些属性中的任何一个,则用户应调用,或者是否 SelectCommand 替换本身。The user should call RefreshSchema if any of these properties are modified, or if the SelectCommand itself is replaced. 否则 InsertCommand ,、 UpdateCommandDeleteCommand 属性将保留其以前的值。Otherwise the InsertCommand, UpdateCommand, and DeleteCommand properties retain their previous values.

如果调用 Dispose ,将 DbCommandBuilder 从解除关联 DbDataAdapter ,并且不再使用生成的命令。If you call Dispose, the DbCommandBuilder is disassociated from the DbDataAdapter, and the generated commands are no longer used.

构造函数

DbCommandBuilder()

初始化从 DbCommandBuilder 类继承的类的新实例。Initializes a new instance of a class that inherits from the DbCommandBuilder class.

属性

CanRaiseEvents

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

(继承自 Component)
CatalogLocation

获取或设置 DbCommandBuilder 类的实例的 CatalogLocationGets or sets the CatalogLocation for an instance of the DbCommandBuilder class.

CatalogSeparator

获取或设置一个字符串,该字符串用作 DbCommandBuilder 类的实例的目录分隔符。Gets or sets a string used as the catalog separator for an instance of the DbCommandBuilder class.

ConflictOption

指定哪个 ConflictOption 将由 DbCommandBuilder 使用。Specifies which ConflictOption is to be used by the DbCommandBuilder.

Container

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

(继承自 Component)
DataAdapter

获取或设置自动为其生成 Transact-SQL 语句的一个 DbDataAdapter 对象。Gets or sets a DbDataAdapter object for which Transact-SQL statements are automatically generated.

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)
QuotePrefix

获取或设置指定其名称包含空格或保留标记等字符的数据库对象(例如,表或列)时使用的开始字符。Gets or sets the beginning character or characters to use when specifying database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.

QuoteSuffix

获取或设置一个或多个结束字符,供指定其名称中包含空格或保留标记等字符的数据库对象(例如,表或列)时使用。Gets or sets the ending character or characters to use when specifying database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.

SchemaSeparator

获取或设置要用作架构标识符和任何其他标识符之间的分隔符的字符。Gets or sets the character to be used for the separator between the schema identifier and any other identifiers.

SetAllValues

指定 update 语句中是包含所有列值还是仅包含更改的列值。Specifies whether all column values in an update statement are included or only changed ones.

Site

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

(继承自 Component)

方法

ApplyParameterInfo(DbParameter, DataRow, StatementType, Boolean)

允许 DbCommandBuilder 类的提供程序实现处理附加参数属性。Allows the provider implementation of the DbCommandBuilder class to handle additional parameter properties.

CreateObjRef(Type)

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

(继承自 MarshalByRefObject)
Dispose()

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

(继承自 Component)
Dispose(Boolean)

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

Equals(Object)

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

(继承自 Object)
GetDeleteCommand()

获取在数据源中执行删除操作所需的自动生成的 DbCommand 对象。Gets the automatically generated DbCommand object required to perform deletions at the data source.

GetDeleteCommand(Boolean)

获取对数据源执行删除操作所必需的自动生成的 DbCommand 对象,可选择使用列作为参数名。Gets the automatically generated DbCommand object required to perform deletions at the data source, optionally using columns for parameter names.

GetHashCode()

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

(继承自 Object)
GetInsertCommand()

获取在数据源中执行插入操作所需的自动生成的 DbCommand 对象。Gets the automatically generated DbCommand object required to perform insertions at the data source.

GetInsertCommand(Boolean)

获取对数据源执行插入操作所必需的自动生成的 DbCommand 对象,可选择使用列作为参数名。Gets the automatically generated DbCommand object required to perform insertions at the data source, optionally using columns for parameter names.

GetLifetimeService()

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

(继承自 MarshalByRefObject)
GetParameterName(Int32)

@p# 格式返回指定参数的名称。Returns the name of the specified parameter in the format of @p#. 在生成自定义命令生成器时使用。Use when building a custom command builder.

GetParameterName(String)

给定部分参数名,返回完整参数名。Returns the full parameter name, given the partial parameter name.

GetParameterPlaceholder(Int32)

返回该参数在关联的 SQL 语句中的占位符。Returns the placeholder for the parameter in the associated SQL statement.

GetSchemaTable(DbCommand)

返回 DbCommandBuilder 的架构表。Returns the schema table for the DbCommandBuilder.

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)
GetUpdateCommand()

获取在数据源中执行更新操作所需的自动生成的 DbCommand 对象。Gets the automatically generated DbCommand object required to perform updates at the data source.

GetUpdateCommand(Boolean)

获取对数据源执行更新操作所必需的自动生成的 DbCommand 对象,可选择使用列作为参数名。Gets the automatically generated DbCommand object required to perform updates at the data source, optionally using columns for parameter names.

InitializeCommand(DbCommand)

重置 CommandTimeout 上的 TransactionCommandTypeUpdateRowSourceDbCommand 属性。Resets the CommandTimeout, Transaction, CommandType, and UpdateRowSource properties on the DbCommand.

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)
QuoteIdentifier(String)

以正确的目录大小写给定一个不带引号的标识符,返回该标识符的带引号的正确形式,包括正确转义该标识符中嵌入的任何引号。Given an unquoted identifier in the correct catalog case, returns the correct quoted form of that identifier, including properly escaping any embedded quotes in the identifier.

RefreshSchema()

清除与此 DbCommandBuilder 关联的命令。Clears the commands associated with this DbCommandBuilder.

RowUpdatingHandler(RowUpdatingEventArgs)

添加 RowUpdating 事件的事件处理程序。Adds an event handler for the RowUpdating event.

SetRowUpdatingHandler(DbDataAdapter)

注册 DbCommandBuilder 以处理 RowUpdatingDbDataAdapter 事件。Registers the DbCommandBuilder to handle the RowUpdating event for a DbDataAdapter.

ToString()

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

(继承自 Component)
UnquoteIdentifier(String)

给定一个带引号的标识符,返回该标识符的不带引号的正确形式,包括正确地取消转义该标识符中嵌入的任何引号。Given a quoted identifier, returns the correct unquoted form of that identifier, including properly un-escaping any embedded quotes in the identifier.

事件

Disposed

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

(继承自 Component)

适用于

另请参阅