IDbDataAdapter IDbDataAdapter IDbDataAdapter IDbDataAdapter Interface

Definition

Represents a set of command-related properties that are used to fill the DataSet and update a data source, and is implemented by .NET Framework data providers that access relational databases.

public interface class IDbDataAdapter : System::Data::IDataAdapter
public interface IDbDataAdapter : System.Data.IDataAdapter
type IDbDataAdapter = interface
    interface IDataAdapter
Public Interface IDbDataAdapter
Implements IDataAdapter
Derived
Implements

Examples

The following example uses the derived classes, SqlCommand, SqlDataAdapter and SqlConnection, to select records from a data source. The filled DataSet is then returned. To accomplish this, the method is passed an initialized DataSet, a connection string, and a query string that is a Transact-SQL SELECT statement.

private static DataSet SelectRows(DataSet dataset,
    string connectionString,string queryString) 
{
    using (SqlConnection connection = 
        new SqlConnection(connectionString))
    {
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(
            queryString, connection);
        adapter.Fill(dataset);
        return dataset;
    }
}

Public Function SelectRows( _
    ByVal dataSet As DataSet, ByVal connectionString As String, _
    ByVal queryString As String) As DataSet

    Using connection As New SqlConnection(connectionString)
        Dim adapter As New SqlDataAdapter()
        adapter.SelectCommand = New SqlCommand( _
            queryString, connection)
        adapter.Fill(dataSet)
        Return dataSet
    End Using
End Function

Remarks

The IDbDataAdapter interface inherits from the IDataAdapter interface and allows an object to create a DataAdapter designed for use with a relational database. The IDbDataAdapter interface and, optionally, the utility class, DbDataAdapter, allow an inheriting class to implement a DataAdapter class, which represents the bridge between a data source and a DataSet. For more information about DataAdapter classes, see Populating a DataSet from a DataAdapter. For more information about implementing .NET Framework data providers, see [<topic://cpconimplementingnetdataprovider>].

An application does not create an instance of the IDbDataAdapter interface directly, but creates an instance of a class that inherits IDbDataAdapter and DbDataAdapter.

Classes that inherit IDbDataAdapter must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the IDbDataAdapter interface defines the SelectCommand property, and the DbDataAdapter interface defines a Fill method that takes a DataTable as a parameter. In turn, the OleDbDataAdapter class inherits the SelectCommand property and the Fill method, and also defines two additional overloads of the Fill method that take an ADO Recordset object as a parameter.

Notes to Implementers

To promote consistency among .NET Framework data providers, name the inheriting class in the form Prv DataAdapter where Prv is the uniform prefix given to all classes in a specific .NET Framework data provider namespace. For example, Sql is the prefix of the SqlDataAdapter class in the System.Data.SqlClient namespace.

When you inherit from the IDbDataAdapter interface, you should implement the following constructors:

Item Description
PrvDataAdapter() Initializes a new instance of the PrvDataAdapter class.
PrvDataAdapter(PrvCommand selectCommand) Initializes a new instance of the PrvDataAdapter class with the specified SQL SELECT statement.
PrvDataAdapter(string selectCommandText, string selectConnectionString) Initializes a new instance of the PrvDataAdapter class with an SQL SELECT statement and a connection string.
PrvDataAdapter(string selectCommandText, PrvConnection selectConnection) Initializes a new instance of the PrvDataAdapter class with an SQL SELECT statement and a PrvConnection object.

Properties

DeleteCommand DeleteCommand DeleteCommand DeleteCommand

Gets or sets an SQL statement for deleting records from the data set.

InsertCommand InsertCommand InsertCommand InsertCommand

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

SelectCommand SelectCommand SelectCommand SelectCommand

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

UpdateCommand UpdateCommand UpdateCommand UpdateCommand

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

Applies to