.NET Framework Class Library IDataAdapter Interface Allows an object to implement a DataAdapter, and represents a set of methods and mapping action-related properties that are used to fill and update a DataSet and update a data source.
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
Public Interface IDataAdapter
public interface IDataAdapter
public interface class IDataAdapter
type IDataAdapter = interface end
The IDataAdapter type exposes the following members.

Remarks
The IDataAdapter interface allows 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 (ADO.NET). An application does not create an instance of the IDbDataAdapter interface directly, but implements an instance of a class that inherits IDbDataAdapter. Classes that inherit IDataAdapter must implement the inherited members, and they typically define additional members to add provider-specific functionality. For example, the IDataAdapter interface defines a Fill method that takes a DataSet as a parameter. In turn, the OleDbDataAdapter class inherits the Fill method and also defines two additional overloads of the Fill method that take an ADO Recordset object as a parameter. Notes to ImplementersTo 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 IDataAdapter 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 by using the specified SQL SELECT statement. | PrvDataAdapter(string selectCommandText, string selectConnectionString) | Initializes a new instance of the PrvDataAdapter class by using an SQL SELECT statement and a connection string. | PrvDataAdapter(string selectCommandText, PrvConnection selectConnection) | Initializes a new instance of the PrvDataAdapter class by using an SQL SELECT statement and a PrvConnection object. |

Examples
The following example uses the derived classes, SqlCommand, SqlDataAdapter, and SqlConnection, to select records from a database. The filled DataSet is then returned. To do this, the method is passed an initialized DataSet, a connection string, and a query string that is a Transact-SQL SELECT statement.
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
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;
}
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework IDataAdapter (Interfaz) Permite que un objeto implemente un DataAdapter. Representa un conjunto de métodos y propiedades relacionadas con acciones de asignación que se usan para rellenar y actualizar un DataSet y actualizar un origen de datos.
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
Public Interface IDataAdapter
public interface IDataAdapter
public interface class IDataAdapter
type IDataAdapter = interface end
El tipo IDataAdapter expone los siguientes miembros.

Comentarios
La interfaz IDataAdapter permite que una clase heredada implemente una clase DataAdapter, que representa el puente entre un origen de datos y un DataSet. Para obtener más información sobre las clases DataAdapter, vea Rellenar un objeto DataSet desde un objeto DataAdapter (ADO.NET). Una aplicación no crea una instancia de la interfaz IDbDataAdapter directamente, sino que implementa una instancia de una clase que hereda IDbDataAdapter. Las clases que heredan IDataAdapter deben implementar los miembros heredados y suelen definir miembros adicionales para agregar la funcionalidad específica del proveedor. Por ejemplo, la interfaz IDataAdapter define un método Fill que toma un DataSet como parámetro. A su vez, la clase OleDbDataAdapter hereda el método Fill y también define dos sobrecargas adicionales del método Fill que toman un objeto ADO Recordset como parámetro. Notas para los implementadoresPara potenciar la coherencia entre los proveedores de datos de .NET Framework, asigne a la clase heredada un nombre con el formato Prv DataAdapter, donde Prv es el prefijo uniforme que se asigna a todas las clases de un espacio de nombres de proveedor de datos de .NET Framework específico. Por ejemplo, Sql es el prefijo de la clase SqlDataAdapter en el espacio de nombres System.Data.SqlClient. Al heredar de la interfaz IDataAdapter, se deben implementar los siguientes constructores: Elemento | Descripción |
|---|
PrvDataAdapter() | Inicializa una nueva instancia de la clase PrvDataAdapter. | PrvDataAdapter(PrvCommand selectCommand) | Inicializa una nueva instancia de la clase PrvDataAdapter con la instrucción SELECT de SQL especificada. | PrvDataAdapter(string selectCommandText, string selectConnectionString) | Inicializa una nueva instancia de la clase PrvDataAdapter con una instrucción SELECT de SQL y una cadena de conexión. | PrvDataAdapter(string selectCommandText, PrvConnection selectConnection) | Inicializa una nueva instancia de la clase PrvDataAdapter con una instrucción SELECT de SQL y un objeto PrvConnection. |

Ejemplos
En el ejemplo siguiente se usan las clases derivadas SqlCommand, SqlDataAdapter y SqlConnection para seleccionar registros de una base de datos. A continuación, se devuelve DataSet rellenado. Para hacer esto, al método se le pasa un DataSet inicializado, una cadena de conexión y una cadena de consulta, que es una instrucción SELECT de Transact-SQL.
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
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;
}
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|