Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IDbDataAdapter Interface

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.

For a list of all members of this type, see IDbDataAdapter Members.

System.Data.IDataAdapter
   System.Data.IDbDataAdapter

[Visual Basic]
Public Interface IDbDataAdapter
   Inherits IDataAdapter
[C#]
public interface IDbDataAdapter : IDataAdapter
[C++]
public __gc __interface IDbDataAdapter : public IDataAdapter
[JScript]
public interface IDbDataAdapter implements IDataAdapter

Classes that Implement IDbDataAdapter

Class Description
OdbcDataAdapter 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.
OleDbDataAdapter Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
OracleDataAdapter Represents a set of data commands and a connection to a database that are used to fill the DataSet and update the database. This class cannot be inherited.
SqlCeDataAdapter Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.
SqlDataAdapter Represents a set of data commands and a database connection that are used to fill the DataSet and update a SQL Server database. This class cannot be inherited.

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 Implementing a .NET Framework Data Provider.

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.

Example

[Visual Basic, C#, C++] 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.

[Visual Basic] 
Public Function SelectSqlSrvRows(dataSet As DataSet, connection As String, query As String) As DataSet
    Dim conn As New SqlConnection(connection)
    Dim adapter As New SqlDataAdapter()
    adapter.SelectCommand = new SqlCommand(query, conn)
    adapter.Fill(dataset)
    Return dataset
End Function

[C#] 
public DataSet SelectSqlSrvRows(DataSet dataset,string connection,string query) 
{
    SqlConnection conn = new SqlConnection(connection);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(query, conn);
    adapter.Fill(dataset);
    return dataset;
}


[C++] 
public:
DataSet* SelectSqlSrvRows(DataSet* dataset,String* connection,String* query) 
{
    SqlConnection* conn = new SqlConnection(connection);
    SqlDataAdapter* adapter = new SqlDataAdapter();
    adapter->SelectCommand = new SqlCommand(query, conn);
    adapter->Fill(dataset);
    return dataset;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

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

See Also

IDbDataAdapter Members | System.Data Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.