Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DbCommandBuilder Class

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.

Namespace:  System.Data.Common
Assembly:  System.Data (in System.Data.dll)
public abstract class DbCommandBuilder : Component

The DbCommandBuilder type exposes the following members.

  NameDescription
Protected methodSupported by the XNA FrameworkDbCommandBuilderInitializes a new instance of a class that inherits from the DbCommandBuilder class.
Top
  NameDescription
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertySupported by the XNA FrameworkCatalogLocationSets or gets the CatalogLocation for an instance of the DbCommandBuilder class.
Public propertySupported by the XNA FrameworkCatalogSeparatorSets or gets a string used as the catalog separator for an instance of the DbCommandBuilder class.
Public propertySupported by the XNA FrameworkConflictOptionSpecifies which ConflictOption is to be used by the DbCommandBuilder.
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Public propertySupported by the XNA FrameworkDataAdapterGets or sets a DbDataAdapter object for which Transact-SQL statements are automatically generated.
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertySupported by the XNA FrameworkEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public propertySupported by the XNA FrameworkQuotePrefixGets 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.
Public propertySupported by the XNA FrameworkQuoteSuffixGets 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.
Public propertySupported by the XNA FrameworkSchemaSeparatorGets or sets the character to be used for the separator between the schema identifier and any other identifiers.
Public propertySupported by the XNA FrameworkSetAllValuesSpecifies whether all column values in an update statement are included or only changed ones.
Public propertySupported by the XNA FrameworkSiteGets or sets the ISite of the Component. (Inherited from Component.)
Top
  NameDescription
Protected methodSupported by the XNA FrameworkApplyParameterInfoAllows the provider implementation of the DbCommandBuilder class to handle additional parameter properties.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkDispose()Releases all resources used by the Component. (Inherited from Component.)
Protected methodSupported by the XNA FrameworkDispose(Boolean)Releases the unmanaged resources used by the DbCommandBuilder and optionally releases the managed resources. (Overrides Component.Dispose(Boolean).)
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Public methodSupported by the XNA FrameworkGetDeleteCommand()Gets the automatically generated DbCommand object required to perform deletions at the data source.
Public methodSupported by the XNA FrameworkGetDeleteCommand(Boolean)Gets the automatically generated DbCommand object required to perform deletions at the data source, optionally using columns for parameter names.
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetInsertCommand()Gets the automatically generated DbCommand object required to perform insertions at the data source.
Public methodSupported by the XNA FrameworkGetInsertCommand(Boolean)Gets the automatically generated DbCommand object required to perform insertions at the data source, optionally using columns for parameter names.
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodSupported by the XNA FrameworkGetParameterName(Int32)Returns the name of the specified parameter in the format of @p#. Use when building a custom command builder.
Protected methodSupported by the XNA FrameworkGetParameterName(String)Infrastructure. Returns the full parameter name, given the partial parameter name.
Protected methodSupported by the XNA FrameworkGetParameterPlaceholderInfrastructure. Returns the placeholder for the parameter in the associated SQL statement.
Protected methodSupported by the XNA FrameworkGetSchemaTableReturns the schema table for the DbCommandBuilder.
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetUpdateCommand()Gets the automatically generated DbCommand object required to perform updates at the data source.
Public methodSupported by the XNA FrameworkGetUpdateCommand(Boolean)Gets the automatically generated DbCommand object required to perform updates at the data source, optionally using columns for parameter names.
Protected methodSupported by the XNA FrameworkInitializeCommandResets the CommandTimeout, Transaction, CommandType, and UpdateRowSource properties on the DbCommand.
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodSupported by the XNA FrameworkMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodSupported by the XNA FrameworkQuoteIdentifierGiven 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.
Public methodSupported by the XNA FrameworkRefreshSchemaClears the commands associated with this DbCommandBuilder.
Protected methodSupported by the XNA FrameworkRowUpdatingHandlerAdds an event handler for the RowUpdating event.
Protected methodSupported by the XNA FrameworkSetRowUpdatingHandlerRegisters the DbCommandBuilder to handle the RowUpdating event for a DbDataAdapter.
Public methodSupported by the XNA FrameworkToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)

In XNA Framework 3.0, this member is inherited from Object.ToString().
Public methodSupported by the XNA FrameworkUnquoteIdentifierGiven a quoted identifier, returns the correct unquoted form of that identifier, including properly un-escaping any embedded quotes in the identifier.
Top
  NameDescription
Public eventSupported by the XNA FrameworkDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Top

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.