System.Data.OleDb.OleDbCommandBuilder Class

Automatically generates single-table commands that are used to reconcile changes made to a System.Data.DataSet with the associated database. This class cannot be inherited.

See Also: OleDbCommandBuilder Members


public sealed class OleDbCommandBuilder : System.Data.Common.DbCommandBuilder


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

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

To generate INSERT, UPDATE, or DELETE statements, the System.Data.OleDb.OleDbCommandBuilder uses the OleDbDataAdapter.SelectCommand property to retrieve a required set of metadata automatically. If you change the OleDbDataAdapter.SelectCommand after the metadata is retrieved, such as after the first update, you should call the System.Data.Common.DbCommandBuilder.RefreshSchema method to update the metadata.

The System.Data.OleDb.OleDbCommandBuilder also uses the OleDbCommand.Connection, OleDbCommand.CommandTimeout, and OleDbCommand.Transaction properties referenced by the OleDbDataAdapter.SelectCommand. The user should call System.Data.Common.DbCommandBuilder.RefreshSchema if one or more of these properties are modified, or if the OleDbDataAdapter.SelectCommand itself is replaced. Otherwise the OleDbDataAdapter.InsertCommand, OleDbDataAdapter.UpdateCommand, and OleDbDataAdapter.DeleteCommand properties retain their previous values.

If you call System.ComponentModel.Component.Dispose, the System.Data.OleDb.OleDbCommandBuilder is disassociated from the System.Data.OleDb.OleDbDataAdapter, and the generated commands are no longer used.


Namespace: System.Data.OleDb
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,