What is OleDbDataAdapter

The OleDbDataAdapter is a class in the .NET Framework that provides a bridge between a data source, such as a database, and a dataset. It is specifically designed for working with data sources that support the OLE DB (Object Linking and Embedding Database) technology, such as Microsoft Access or SQL Server.

The OleDbDataAdapter is part of the ADO.NET (ActiveX Data Objects for .NET) technology, which is a set of classes used to interact with different data sources in a consistent manner. It acts as a mediator between a data source and a dataset, enabling you to retrieve and manipulate data.

Full Source VB.NET
Imports System.Data.OleDb Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim connetionString As String Dim oledbCnn As OleDbConnection Dim oledbAdapter As OleDbDataAdapter Dim ds As New DataSet Dim sql As String Dim i As Integer connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;" sql = "Your SQL Statement Here like Select * from product" oledbCnn = New OleDbConnection(connetionString) Try oledbCnn.Open() oledbAdapter = New OleDbDataAdapter(sql, oledbCnn) oledbAdapter.Fill(ds) For i = 0 To ds.Tables(0).Rows.Count - 1 MsgBox(ds.Tables(0).Rows(i).Item(0) & " -- " & ds.Tables(0).Rows(i).Item(1)) Next oledbAdapter.Dispose() oledbCnn.Close() Catch ex As Exception MsgBox("Can not open connection ! ") End Try End Sub End Class

Key features and functionalities of the OleDbDataAdapter

  1. Data Retrieval: The OleDbDataAdapter allows you to retrieve data from a data source by executing SQL queries or stored procedures. It establishes a connection to the database, executes the query, and fills the retrieved data into a dataset.
  2. Data Manipulation: In addition to retrieving data, the OleDbDataAdapter also provides functionality for inserting, updating, and deleting data in the data source. It generates the necessary SQL statements to perform these operations based on changes made to the dataset.
  3. Dataset Integration: The OleDbDataAdapter works closely with a dataset, which is an in-memory representation of data. It populates the dataset with data retrieved from the data source and applies any changes made to the dataset back to the data source. This allows you to work with disconnected data, making it easier to manipulate and update data without constant interaction with the database.
  4. Automatic Command Generation: The OleDbDataAdapter automatically generates the SQL commands required to interact with the data source based on the changes made to the dataset. This includes generating INSERT, UPDATE, and DELETE statements based on the modified rows in the dataset.
  5. Connection Management: The OleDbDataAdapter manages the database connection internally, including opening and closing the connection when necessary. It provides options to specify the connection string and other connection-related properties to establish the connection with the data source.
  6. Data Mapping: The OleDbDataAdapter maps the columns of the dataset to the corresponding columns in the data source. It ensures that data is correctly transferred between the dataset and the database by matching column names and data types.


The OleDbDataAdapter simplifies the process of working with data from OLE DB-compatible data sources in .NET applications. It provides a flexible and efficient means to retrieve, manipulate, and update data, making it easier to build database-driven applications.