DataGridView binding - OLEDB in VB.NET

The DataGridView control offers three modes of data display: Bound mode, Unbound mode, and Virtual mode. When starting out with the DataGridView, utilizing basic data binding scenarios is the most straightforward approach. By specifying a data source for the DataGridView, you can easily display rows of data. In the process, the control automatically generates columns based on the data types found in the data source.

Bound mode, in particular, simplifies the process of displaying data by establishing a direct connection between the DataGridView and the data source. When binding a data source, the control automatically creates the appropriate columns to accommodate the data. These columns are generated based on the data types present in the data source, ensuring that the displayed data aligns correctly with its respective data types.

By using bound mode, you can effortlessly display and manage large sets of data with minimal effort. The DataGridView's built-in data binding capabilities streamline the process of populating and synchronizing the control with the data source. As a result, you can focus on the presentation and manipulation of the data without worrying about manually configuring the columns.

The following vb.net program shows how to bind an OLEDB dataset in a DataGridView.

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 connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="Your .mdb path";" Dim sql As String = "SELECT * FROM Authors" Dim connection As New OleDbConnection(connectionString) Dim dataadapter As New OleDbDataAdapter(sql, connection) Dim ds As New DataSet() connection.Open() dataadapter.Fill(ds, "Authors_table") connection.Close() DataGridView1.DataSource = ds DataGridView1.DataMember = "Authors_table" End Sub End Class

The DataGridView's bound mode offers a convenient and efficient way to display data by automatically generating columns based on the data types in the data source. By utilizing this mode, you can easily showcase rows of data in the DataGridView control without the need for manual column configuration.