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

Syntax

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

Remarks

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.

Note:

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.

Note:

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.

Requirements

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