DataAdapter:
Data adapters are an integral part of ADO.NET
managed providers, which are the set of objects used to communicate between a
data source and a dataset. (In addition to adapters, managed providers include
connection objects, data reader objects, and command objects.)Adapters are used
to exchange data between a data source and a dataset. In many applications, this
means reading data from a database into a dataset, and then writing changed data
from the dataset back to the database. However, a data adapter can move data
between any source and a dataset.
DataAdapter Model:
DataAdapter contain only four commands, that
are:

Note: Generally, adapters are
configurable to allow you to specify what data to move into and out of the
dataset. Often this takes the form of references to SQL statements or stored
procedures that are invoked to read or write to a database.
OleDbDataAdapter:
The OleDbDataAdapter serves as a bridge between
a DataSet and data source for retrieving and saving data. When the
OleDbDataAdapter fills a DataSet, it will create the necessary tables and
columns for the returned data if they do not already exist.
Syntax of OleDbAdapter in VB.NET:
Public Function SelectOleDb(ByVal
dataSet As DataSet,
ByVal connection As String, ByVal
query As String)
As DataSet
Dim conn As New OleDbConnection(connection)
Dim adapter As New OleDbDataAdapter()
adapter.SelectCommand = New
OleDbCommand(query, conn)
adapter.Fill(dataSet)
Return dataSet
End Function
Steps in
OleDbAdapter in VB.NET:
Module1
Coding:
Imports
System.Data.OleDb
Module Module1
Public constring As
OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=D:\my_db.accdb")
End Module
Form Coding:
Imports
System.Data.OleDb
Public Class Form1
Dim cmd As
OleDbCommand
Dim reader As
OleDbDataReader
Dim SqlString As String
Dim numAffected
As Integer
Dim S As String
Dim Ds As
DataSet
Dim Da As
OleDbDataAdapter
Private Sub
Label2_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles Label2.Click
End Sub
Private Sub
TextBox2_TextChanged(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles TextBox2.TextChanged
End Sub
Private Sub
Button4_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles Button4.Click
Me.Close()
End Sub
Private Sub
DataGridView1_CellContentClick(ByVal sender
As System.Object, ByVal
e As
System.Windows.Forms.DataGridViewCellEventArgs)
End Sub
Private Sub
Form1_Load(ByVal sender
As System.Object, ByVal e
As System.EventArgs)
Handles MyBase.Load
End Sub
Private Sub
Button1_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles Button1.Click
Try
constring.Open()
SqlString = "insert into info values("
SqlString += """" &
TextBox1.Text & """"
SqlString += ","
SqlString += """" &
TextBox2.Text & """"
SqlString += ","
SqlString += """" &
TextBox3.Text & """"
SqlString += ")"
cmd = New OleDbCommand(SqlString,
constring)
cmd.ExecuteNonQuery()
MessageBox.Show("a record has been
successfully added")
Catch ex As
Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub
Button3_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs)
Handles Button3.Click
Try
Ds = New DataSet
SqlString = "select * from info"
Da = New
OleDbDataAdapter(SqlString, constring)
Da.Fill(Ds, "info")
DataGridView1.DataSource = Ds.Tables(0)
Catch ex As
Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub
DataGridView1_CellContentClick_1(ByVal sender
As System.Object, ByVal
e AsSystem.Windows.Forms.DataGridViewCellEventArgs)
Handles DataGridView1.CellContentClick
End Sub
End Class
Output:


Additional Resource: MSDN