System.Data.Odbc.OdbcDataAdapter Class

Represents a set of data commands and a connection to a data source that are used to fill the System.Data.DataSet and update the data source. This class cannot be inherited.

See Also: OdbcDataAdapter Members


[System.ComponentModel.ToolboxItem("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterToolboxItem, Microsoft.VSDesigner, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.Designer("Microsoft.VSDesigner.Data.VS.OdbcDataAdapterDesigner, Microsoft.VSDesigner, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public sealed class OdbcDataAdapter : System.Data.Common.DbDataAdapter


The System.Data.Odbc.OdbcDataAdapter serves as a bridge between a DataSet and data source for retrieving and saving data. The System.Data.Odbc.OdbcDataAdapter provides this bridge by using System.Data.Common.DbDataAdapter.Fill(System.Data.DataSet) to load data from the data source into the System.Data.DataSet, and using System.Data.Common.DbDataAdapter.Update(System.Data.DataSet) to send changes made in the System.Data.DataSet back to the data source.

When the System.Data.Odbc.OdbcDataAdapter fills a System.Data.DataSet, it creates the required tables and columns for the returned data if they do not already exist. However, primary key information is not included in the implicitly created schema unless the System.Data.Common.DataAdapter.MissingSchemaAction property is set to System.Data.MissingSchemaAction.AddWithKey. You may also have the System.Data.Odbc.OdbcDataAdapter create the schema of the System.Data.DataSet, including primary key information, before filling it with data using System.Data.Common.DbDataAdapter.FillSchema(System.Data.DataTable, System.Data.SchemaType). For more information, see Adding Existing Constraints to a DataSet.


When you call the Fill method on a data source that does not have a primary key column, the System.Data.Odbc.OdbcDataAdapter tries to promote the unique constraint column to the primary key. In the process, the System.Data.Odbc.OdbcDataAdapter marks the unique constraint as not nullable. This behavior works unless there is a null value in the unique constraint column. If there is a null value, the Fill method fails with a constraint violation. To avoid this situation, do not allow null values in the unique constraint column.


Due to the limitations of native ODBC drivers, only one System.Data.DataTable is ever returned when you call System.Data.Common.DbDataAdapter.FillSchema(System.Data.DataTable, System.Data.SchemaType). This is true even when executing SQL batch statements from which multiple System.Data.DataTable objects would be expected.

The System.Data.Odbc.OdbcDataAdapter also includes the OdbcDataAdapter.SelectCommand, OdbcDataAdapter.InsertCommand, OdbcDataAdapter.DeleteCommand, OdbcDataAdapter.UpdateCommand, and TableMappings properties to facilitate loading and updating of data.


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