SiteMap  | About    

DataGridView Binding - OLEDB dataset

The DataGridView can display data in Bound mode and unbound mode and Virtual mode. The easiest way to get started using the DataGridView control is to use it in basic data-binding scenarios. When you specify a data source for the DataGridView, by default it will construct columns for you automatically. This will be created based on the data types in the data source.

The following C# program shows how to bind an OLEDB dataset to a DataGridView.

using System;
using System.Data;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsApplication1
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)
            string connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=your .mdb file;";
            string sql = "SELECT * FROM Authors";
            OleDbConnection connection = new OleDbConnection(connetionString);
            OleDbDataAdapter dataadapter = new OleDbDataAdapter(sql, connection);
            DataSet ds = new DataSet();
            dataadapter.Fill(ds, "Authors_table");
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "Authors_table";
} (C) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.