DbCommandBuilder DbCommandBuilder DbCommandBuilder DbCommandBuilder Class

Definition

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
Inheritance

Remarks

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.

The DbDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a DataSet with the associated data source. However, you can create a DbCommandBuilder object to automatically generate SQL statements for single-table updates if you set the SelectCommand property of the DbDataAdapter. Then, any additional SQL statements that you do not set are generated by the DbCommandBuilder.

The DbCommandBuilder registers itself as a listener for RowUpdating events whenever you set the DataAdapter property. You can only associate one DbDataAdapter or DbCommandBuilder object with each other at one time.

To generate INSERT, UPDATE, or DELETE statements, the DbCommandBuilder uses the SelectCommand property to retrieve a required set of metadata automatically. 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.

The SelectCommand must also return at least one primary key or unique column. If none exist, an InvalidOperationException exception is generated, and the commands are not generated.

The DbCommandBuilder also uses the Connection, CommandTimeout, and Transaction properties referenced by the SelectCommand. The user should call RefreshSchema if any of these properties are modified, or if the SelectCommand itself is replaced. Otherwise the InsertCommand, UpdateCommand, and DeleteCommand properties retain their previous values.

If you call Dispose, the DbCommandBuilder is disassociated from the DbDataAdapter, and the generated commands are no longer used.

Constructors

DbCommandBuilder() DbCommandBuilder() DbCommandBuilder() DbCommandBuilder()

Initializes a new instance of a class that inherits from the DbCommandBuilder class.

Properties

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
CatalogLocation CatalogLocation CatalogLocation CatalogLocation

Sets or gets the CatalogLocation for an instance of the DbCommandBuilder class.

CatalogSeparator CatalogSeparator CatalogSeparator CatalogSeparator

Sets or gets a string used as the catalog separator for an instance of the DbCommandBuilder class.

ConflictOption ConflictOption ConflictOption ConflictOption

Specifies which ConflictOption is to be used by the DbCommandBuilder.

Container Container Container Container

Gets the IContainer that contains the Component.

(Inherited from Component)
DataAdapter DataAdapter DataAdapter DataAdapter

Gets or sets a DbDataAdapter object for which Transact-SQL statements are automatically generated.

DesignMode DesignMode DesignMode DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
QuotePrefix QuotePrefix QuotePrefix 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 QuoteSuffix QuoteSuffix 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 SchemaSeparator SchemaSeparator SchemaSeparator

Gets or sets the character to be used for the separator between the schema identifier and any other identifiers.

SetAllValues SetAllValues SetAllValues SetAllValues

Specifies whether all column values in an update statement are included or only changed ones.

Site Site Site Site

Gets or sets the ISite of the Component.

(Inherited from Component)

Methods

ApplyParameterInfo(DbParameter, DataRow, StatementType, Boolean) ApplyParameterInfo(DbParameter, DataRow, StatementType, Boolean) ApplyParameterInfo(DbParameter, DataRow, StatementType, Boolean) ApplyParameterInfo(DbParameter, DataRow, StatementType, Boolean)

Allows the provider implementation of the DbCommandBuilder class to handle additional parameter properties.

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

Releases all resources used by the Component.

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

Releases the unmanaged resources used by the DbCommandBuilder 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)
GetDeleteCommand() GetDeleteCommand() GetDeleteCommand() GetDeleteCommand()

Gets the automatically generated DbCommand object required to perform deletions at the data source.

GetDeleteCommand(Boolean) GetDeleteCommand(Boolean) GetDeleteCommand(Boolean) GetDeleteCommand(Boolean)

Gets the automatically generated DbCommand object required to perform deletions at the data source, optionally using columns for parameter names.

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

Serves as the default hash function.

(Inherited from Object)
GetInsertCommand() GetInsertCommand() GetInsertCommand() GetInsertCommand()

Gets the automatically generated DbCommand object required to perform insertions at the data source.

GetInsertCommand(Boolean) GetInsertCommand(Boolean) GetInsertCommand(Boolean) GetInsertCommand(Boolean)

Gets the automatically generated DbCommand object required to perform insertions at the data source, optionally using columns for parameter names.

GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetParameterName(Int32) GetParameterName(Int32) GetParameterName(Int32) GetParameterName(Int32)

Returns the name of the specified parameter in the format of @p#. Use when building a custom command builder.

GetParameterName(String) GetParameterName(String) GetParameterName(String) GetParameterName(String)

Returns the full parameter name, given the partial parameter name.

GetParameterPlaceholder(Int32) GetParameterPlaceholder(Int32) GetParameterPlaceholder(Int32) GetParameterPlaceholder(Int32)

Returns the placeholder for the parameter in the associated SQL statement.

GetSchemaTable(DbCommand) GetSchemaTable(DbCommand) GetSchemaTable(DbCommand) GetSchemaTable(DbCommand)

Returns the schema table for the DbCommandBuilder.

GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

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

Gets the Type of the current instance.

(Inherited from Object)
GetUpdateCommand() GetUpdateCommand() GetUpdateCommand() GetUpdateCommand()

Gets the automatically generated DbCommand object required to perform updates at the data source.

GetUpdateCommand(Boolean) GetUpdateCommand(Boolean) GetUpdateCommand(Boolean) GetUpdateCommand(Boolean)

Gets the automatically generated DbCommand object required to perform updates at the data source, optionally using columns for parameter names.

InitializeCommand(DbCommand) InitializeCommand(DbCommand) InitializeCommand(DbCommand) InitializeCommand(DbCommand)

Resets the CommandTimeout, Transaction, CommandType, and UpdateRowSource properties on the DbCommand.

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

Obtains a lifetime service object to control the lifetime policy for this instance.

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

Creates a shallow copy of the current Object.

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

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
QuoteIdentifier(String) QuoteIdentifier(String) QuoteIdentifier(String) 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() RefreshSchema() RefreshSchema() RefreshSchema()

Clears the commands associated with this DbCommandBuilder.

RowUpdatingHandler(RowUpdatingEventArgs) RowUpdatingHandler(RowUpdatingEventArgs) RowUpdatingHandler(RowUpdatingEventArgs) RowUpdatingHandler(RowUpdatingEventArgs)

Adds an event handler for the RowUpdating event.

SetRowUpdatingHandler(DbDataAdapter) SetRowUpdatingHandler(DbDataAdapter) SetRowUpdatingHandler(DbDataAdapter) SetRowUpdatingHandler(DbDataAdapter)

Registers the DbCommandBuilder to handle the RowUpdating event for a DbDataAdapter.

ToString() ToString() ToString() ToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)
UnquoteIdentifier(String) UnquoteIdentifier(String) UnquoteIdentifier(String) UnquoteIdentifier(String)

Given a quoted identifier, returns the correct unquoted form of that identifier, including properly un-escaping any embedded quotes in the identifier.

Events

Disposed Disposed Disposed Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

Applies to

See Also