Automatically generates single-table commands that are used to reconcile changes made to a System.Data.DataSet with the associated data source. This class cannot be inherited.
See Also: OdbcCommandBuilder Members
The System.Data.Odbc.OdbcDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a System.Data.DataSet associated with the data source. However, you can create an System.Data.Odbc.OdbcCommandBuilder object that generates SQL statements for single-table updates by setting the OdbcDataAdapter.SelectCommand property of the System.Data.Odbc.OdbcDataAdapter. The System.Data.Odbc.OdbcCommandBuilder then generates any additional SQL statements that you do not set.
The relationship between an System.Data.Odbc.OdbcDataAdapter and its corresponding System.Data.Odbc.OdbcCommandBuilder is always one-to-one. To create this correspondence, you set the System.Data.Odbc.OdbcDataAdapter property of the System.Data.Odbc.OdbcCommandBuilder object. This causes the System.Data.Odbc.OdbcCommandBuilder to register itself as a listener, which produces the output of OdbcDataAdapter.RowUpdating events that affect the System.Data.DataSet.
To generate INSERT, UPDATE, or DELETE statements, the System.Data.Odbc.OdbcCommandBuilder uses the OdbcDataAdapter.SelectCommand property to retrieve a required set of metadata. If you change the value of OdbcDataAdapter.SelectCommand after the metadata has been retrieved, such as after the first update, you should then call the System.Data.Common.DbCommandBuilder.RefreshSchema method to update the metadata.
If the SELECT statement assigned to the OdbcDataAdapter.SelectCommand property uses aliased column names, the resulting INSERT, UPDATE, and DELETE statements may be inaccurate or fail. If the underlying ODBC driver cannot provide the appropriate base column name for the alias column name (using the SQL_DESC_BASE_COLUMN_NAME value of SQLColAttribute), the alias name could be used in the generated INSERT, UPDATE, and DELETE statements. For example, the Microsoft ODBC Driver for Oracle returns the alias name as the base column name. Therefore, the generated INSERT, UPDATE, and DELETE statements would cause errors.
The System.Data.Odbc.OdbcCommandBuilder also uses the OdbcCommand.Connection, OdbcCommand.CommandTimeout, and OdbcCommand.Transaction properties referenced by the OdbcDataAdapter.SelectCommand. The user should call System.Data.Common.DbCommandBuilder.RefreshSchema if one or more of these properties are modified, or if the value of the OdbcDataAdapter.SelectCommand property itself is changed. Otherwise the OdbcDataAdapter.InsertCommand, OdbcDataAdapter.UpdateCommand, and OdbcDataAdapter.DeleteCommand properties retain their previous values.