DataAdapter Class

Definition

Represents a set of SQL commands and a database connection that are used to fill the DataSet and update the data source.

public class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
public abstract class DataAdapter : System.ComponentModel.Component, System.Data.IDataAdapter
Inheritance
Derived
Implements

Remarks

The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet.

If you are connecting to a SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand and SqlConnection objects. For OLE DB-supported data sources, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects. For ODBC-supported data sources, use the DataAdapter with its associated OdbcCommand and OdbcConnection objects. For Oracle databases, use the DataAdapter with its associated OracleCommand and OracleConnection objects.

When an instance of DataAdapter is created, the read/write properties are set to initial values. For a list of these values, see the DataAdapter constructor.

Constructors

DataAdapter()

Initializes a new instance of the DataAdapter class.

DataAdapter(DataAdapter)

Initializes a new instance of the DataAdapter class from an existing object of the same type.

Properties

AcceptChangesDuringFill

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.

AcceptChangesDuringUpdate

Gets or sets whether AcceptChanges() is called during a Update(DataSet).

CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container

Gets the IContainer that contains the Component.

(Inherited from Component)
ContinueUpdateOnError

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

DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
FillLoadOption

Gets or sets the LoadOption that determines how the adapter fills the DataTable from the DbDataReader.

MissingMappingAction

Determines the action to take when incoming data does not have a matching table or column.

MissingSchemaAction

Determines the action to take when existing DataSet schema does not match incoming data.

ReturnProviderSpecificTypes

Gets or sets whether the Fill method should return provider-specific values or common CLS-compliant values.

Site

Gets or sets the ISite of the Component.

(Inherited from Component)
TableMappings

Gets a collection that provides the primary mapping between a source table and a DataTable.

Methods

CloneInternals()
Obsolete.
Obsolete.
Obsolete.
Obsolete.

Creates a copy of this instance of DataAdapter.

CreateObjRef(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)
CreateTableMappings()

Creates a new DataTableMappingCollection.

Dispose()

Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean)

Releases the unmanaged resources used by the DataAdapter and optionally releases the managed resources.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Fill(DataSet, String, IDataReader, Int32, Int32)

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

Fill(DataSet)

Adds or refreshes rows in the DataSet to match those in the data source.

Fill(DataTable, IDataReader)

Adds or refreshes rows in the DataTable to match those in the data source using the DataTable name and the specified IDataReader.

Fill(DataTable[], IDataReader, Int32, Int32)

Adds or refreshes rows in a specified range in the collection of DataTable objects to match those in the data source.

FillSchema(DataSet, SchemaType, String, IDataReader)

Adds a DataTable to the specified DataSet.

FillSchema(DataSet, SchemaType)

Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.

FillSchema(DataTable, SchemaType, IDataReader)

Adds a DataTable to the specified DataSet.

GetFillParameters()

Gets the parameters set by the user when executing an SQL SELECT statement.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService()
Obsolete.

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
HasTableMappings()

Indicates whether a DataTableMappingCollection has been created.

InitializeLifetimeService()
Obsolete.

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnFillError(FillErrorEventArgs)

Invoked when an error occurs during a Fill.

ResetFillLoadOption()

Resets FillLoadOption to its default state and causes Fill(DataSet) to honor AcceptChangesDuringFill.

ShouldSerializeAcceptChangesDuringFill()

Determines whether the AcceptChangesDuringFill property should be persisted.

ShouldSerializeFillLoadOption()

Determines whether the FillLoadOption property should be persisted.

ShouldSerializeTableMappings()

Determines whether one or more DataTableMapping objects exist and they should be persisted.

ToString()

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

(Inherited from Component)
Update(DataSet)

Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet from a DataTable named "Table."

Events

Disposed

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

(Inherited from Component)
FillError

Returned when an error occurs during a fill operation.

Explicit Interface Implementations

IDataAdapter.TableMappings

Gets a collection that indicates how a source table is mapped to a dataset table.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

See also