DataAdapter

DataAdapter
DeveloperMicrosoft
Written inC# (reference implementation)
Platform.NET Framework, .NET
Included withSystem.Data/System.Data.Common
TypeData access component (ADO.NET)

In ADO.NET, a data adapter (DataAdapter) is an object that acts as a bridge between a data source and a disconnected in-memory data representation such as a DataSet, enabling data to be retrieved into the DataSet and later written back to the data source.[1][2]

Overview

The DataAdapter is an abstract base class in the System.Data.Common namespace; provider-specific implementations (such as for SQL Server, OLE DB, or ODBC) typically derive from DbDataAdapter.[1][3] Data adapters are used with the ADO.NET disconnected model, where an application loads data into a memory-resident DataSet (including related tables, constraints, and relationships) and later reconciles changes back to the underlying data source.[4]

Operation

Filling a DataSet

A DataAdapter populates a DataSet (or DataTable) through its Fill method, using its SelectCommand to retrieve rows from the data source.[5]

Updating the data source

A DataAdapter can persist changes made in the DataSet back to the data source using Update; it applies INSERT, UPDATE and DELETE operations as appropriate based on changes tracked in the DataSet, using command objects such as InsertCommand, UpdateCommand and DeleteCommand.[6]

Schema and table mappings

Data adapters can also configure a DataSet's schema from the data source (for example, using FillSchema) and can map source table names to DataTable names through table mappings.[7][3]

Implementations

Provider-specific data adapters include:

  • SqlDataAdapter for Microsoft SQL Server (System.Data.SqlClient)[8]
  • OleDbDataAdapter for OLE DB data sources (System.Data.OleDb)[9]
  • OdbcDataAdapter for ODBC data sources (System.Data.Odbc)[10]

A DataSet can be filled and updated using multiple DataAdapter instances, and can contain related tables originating from different data sources exposed through different providers.[11]

See also

References

  1. ^ a b "DataAdapter Class (System.Data.Common)". Microsoft Learn. Retrieved 13 December 2025.
  2. ^ "ADO.NET architecture". Microsoft Learn. 15 September 2021. Retrieved 13 December 2025.
  3. ^ a b "DbDataAdapter Class (System.Data.Common)". Microsoft Learn. Retrieved 13 December 2025.
  4. ^ "ADO.NET DataSets". Microsoft Learn. 15 September 2021. Retrieved 13 December 2025.
  5. ^ "Populating a DataSet from a DataAdapter". Microsoft Learn. 15 September 2021. Retrieved 13 December 2025.
  6. ^ "Updating Data Sources with DataAdapters". Microsoft Learn. 29 November 2021. Retrieved 13 December 2025.
  7. ^ "DataAdapter.FillSchema Method (System.Data.Common)". Microsoft Learn. Retrieved 13 December 2025.
  8. ^ "SqlDataAdapter Class (System.Data.SqlClient)". Microsoft Learn. Retrieved 13 December 2025.
  9. ^ "OleDbDataAdapter Class (System.Data.OleDb)". Microsoft Learn. Retrieved 13 December 2025.
  10. ^ "OdbcDataAdapter Class (System.Data.Odbc)". Microsoft Learn. Retrieved 13 December 2025.
  11. ^ "Populate a DataSet from a DataAdapter". Microsoft Learn. 4 September 2024. Retrieved 13 December 2025.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.