OdbcDataAdapter Class

OdbcDataAdapter Class

 

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

Namespace:   System.Data.Odbc
Assembly:  System.Data (in System.Data.dll)

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Data.Common.DataAdapter
        System.Data.Common.DbDataAdapter
          System.Data.Odbc.OdbcDataAdapter

public sealed class OdbcDataAdapter : DbDataAdapter, IDbDataAdapter, 
	IDataAdapter, ICloneable

NameDescription
System_CAPS_pubmethodOdbcDataAdapter()

Initializes a new instance of the OdbcDataAdapter class.

System_CAPS_pubmethodOdbcDataAdapter(OdbcCommand)

Initializes a new instance of the OdbcDataAdapter class with the specified SQL SELECT statement.

System_CAPS_pubmethodOdbcDataAdapter(String, OdbcConnection)

Initializes a new instance of the OdbcDataAdapter class with an SQL SELECT statement and an OdbcConnection.

System_CAPS_pubmethodOdbcDataAdapter(String, String)

Initializes a new instance of the OdbcDataAdapter class with an SQL SELECT statement and a connection string.

NameDescription
System_CAPS_pubpropertyAcceptChangesDuringFill

Gets or sets a value indicating whether AcceptChanges is called on a DataRow after it is added to the DataTable during any of the Fill operations.(Inherited from DataAdapter.)

System_CAPS_pubpropertyAcceptChangesDuringUpdate

Gets or sets whether AcceptChanges is called during a Update.(Inherited from DataAdapter.)

System_CAPS_pubpropertyContainer

Gets the IContainer that contains the Component.(Inherited from Component.)

System_CAPS_pubpropertyContinueUpdateOnError

Gets or sets a value that specifies whether to generate an exception when an error is encountered during a row update.(Inherited from DataAdapter.)

System_CAPS_pubpropertyDeleteCommand

Gets or sets an SQL statement or stored procedure used to delete records in the data source.

System_CAPS_protpropertyFillCommandBehavior

Gets or sets the behavior of the command used to fill the data adapter.(Inherited from DbDataAdapter.)

System_CAPS_pubpropertyFillLoadOption

Gets or sets the LoadOption that determines how the adapter fills the DataTable from the DbDataReader.(Inherited from DataAdapter.)

System_CAPS_pubpropertyInsertCommand

Gets or sets an SQL statement or stored procedure used to insert new records into the data source.

System_CAPS_pubpropertyMissingMappingAction

Determines the action to take when incoming data does not have a matching table or column.(Inherited from DataAdapter.)

System_CAPS_pubpropertyMissingSchemaAction

Determines the action to take when existing DataSet schema does not match incoming data.(Inherited from DataAdapter.)

System_CAPS_pubpropertyReturnProviderSpecificTypes

Gets or sets whether the Fill method should return provider-specific values or common CLS-compliant values.(Inherited from DataAdapter.)

System_CAPS_pubpropertySelectCommand

Gets or sets an SQL statement or stored procedure used to select records in the data source.

System_CAPS_pubpropertySite

Gets or sets the ISite of the Component.(Inherited from Component.)

System_CAPS_pubpropertyTableMappings

Gets a collection that provides the master mapping between a source table and a DataTable.(Inherited from DataAdapter.)

System_CAPS_pubpropertyUpdateBatchSize

Gets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch. (Inherited from DbDataAdapter.)

System_CAPS_pubpropertyUpdateCommand

Gets or sets an SQL statement or stored procedure used to update records in the data source.

NameDescription
System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the Component.(Inherited from Component.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodFill(DataSet)

Adds or refreshes rows in the DataSet.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFill(DataSet, Int32, Int32, String)

Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFill(DataSet, String)

Adds or refreshes rows in the DataSet to match those in the data source using the DataSet and DataTable names.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFill(DataTable)

Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataTable name.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFill(Int32, Int32, DataTable[])

Adds or refreshes rows in a DataTable to match those in the data source starting at the specified record and retrieving up to the specified maximum number of records.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFillSchema(DataSet, SchemaType)

Adds a DataTable named "Table" to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFillSchema(DataSet, SchemaType, String)

Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based upon the specified SchemaType and DataTable.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodFillSchema(DataTable, SchemaType)

Configures the schema of the specified DataTable based on the specified SchemaType.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodGetFillParameters()

Gets the parameters set by the user when executing an SQL SELECT statement.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodResetFillLoadOption()

Resets FillLoadOption to its default state and causes DataAdapter.Fill to honor AcceptChangesDuringFill.(Inherited from DataAdapter.)

System_CAPS_pubmethodShouldSerializeAcceptChangesDuringFill()

Determines whether the AcceptChangesDuringFill property should be persisted.(Inherited from DataAdapter.)

System_CAPS_pubmethodShouldSerializeFillLoadOption()

Determines whether the FillLoadOption property should be persisted.(Inherited from DataAdapter.)

System_CAPS_pubmethodToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.(Inherited from Component.)

System_CAPS_pubmethodUpdate(DataRow[])

Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array in the DataSet.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodUpdate(DataSet)

Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodUpdate(DataSet, String)

Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet with the specified DataTable name.(Inherited from DbDataAdapter.)

System_CAPS_pubmethodUpdate(DataTable)

Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataTable.(Inherited from DbDataAdapter.)

NameDescription
System_CAPS_pubeventDisposed

Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)

System_CAPS_pubeventFillError

Returned when an error occurs during a fill operation.(Inherited from DataAdapter.)

System_CAPS_pubeventRowUpdated

Occurs during an update operation after a command is executed against the data source.

System_CAPS_pubeventRowUpdating

Occurs during Update before a command is executed against the data source.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICloneable.Clone()

For a description of this member, see ICloneable.Clone.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDataAdapter.TableMappings

Indicates how a source table is mapped to a dataset table.(Inherited from DataAdapter.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDbDataAdapter.DeleteCommand

For a description of this member, see M:System.Data.IDbDataAdapter.DeleteCommand.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDbDataAdapter.InsertCommand

For a description of this member, see M:System.Data.IDbDataAdapter.InsertCommand.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDbDataAdapter.SelectCommand

For a description of this member, see M:System.Data.IDbDataAdapter.SelectCommand.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDbDataAdapter.UpdateCommand

For a description of this member, see M:System.Data.IDbDataAdapter.UpdateCommand.

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

When the OdbcDataAdapter fills a 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 MissingSchemaAction property is set to AddWithKey. You may also have the OdbcDataAdapter create the schema of the DataSet, including primary key information, before filling it with data using FillSchema. For more information, see Adding Existing Constraints to a DataSet.

System_CAPS_noteNote

When you call the Fill method on a data source that does not have a primary key column, the OdbcDataAdapter tries to promote the unique constraint column to the primary key. In the process, the 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.

System_CAPS_noteNote

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

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

The following example uses OdbcCommand, OdbcDataAdapter, and OdbcConnection to select records and populate a DataSet with the selected rows.

public DataSet GetDataSetFromAdapter(
    DataSet dataSet, string connectionString, string queryString)
{
    using (OdbcConnection connection = 
               new OdbcConnection(connectionString))
    {
        OdbcDataAdapter adapter = 
            new OdbcDataAdapter(queryString, connection);

        // Open the connection and fill the DataSet.
        try
        {
            connection.Open();
            adapter.Fill(dataSet);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.
    }
    return dataSet;
}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft