# Tutorial: Binding to MS Access DataTable/Database

The following tutorial demonstrates binding to a single database table. For information on binding to multiple tables see the [Binding to Hierarchical Data](https://www.telerik.com/products/winforms/documentation/controls/gridview/hierarchical-grid/binding-to-hierarchical-data) topic.

![WinForms RadGridView Binding to MS Access DataTable/Database](https://www.telerik.com/products/winforms/documentation/assets/1b6805c1ec28367f8babcf254e553750/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset001.png)

> important This tutorial is applicable for Visual Studio 2019 (or prior versions).  If you're using Visual Studio to connect to Access databases, you will need to be aware that versions of Visual Studio prior to Visual Studio 2022 are all 32-bit processes. This means some of the data tools in Visual Studio 2019 and earlier will only be able to connect to Access databases using 32-bit data providers. The last version of Visual Studio that was a 32-bit process was Visual Studio 2019. [READ MORE](https://docs.microsoft.com/en-us/visualstudio/data-tools/connect-to-data-in-an-access-database-windows-forms?view=vs-2022)

1\. Place a **RadGridView** component on a form. Set the **Dock** property to *Fill*.

2\. In the Properties window locate the **DataSource** property and click the arrow to open the list. Select the **Add Project Data Source...** link. *This step will display the Data Source Configuration Wizard.*

![WinForms RadGridView Data Source Configuration Wizard](https://www.telerik.com/products/winforms/documentation/assets/6884619170bc259cc2e8537f3ceb4988/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset002.png)

3\. In the `Data Source Configuration Wizard` **Choose a Data Source Type page**, select the **Database** icon. Click the **Next** button.

![WinForms RadGridView DataSource Type](https://www.telerik.com/products/winforms/documentation/assets/1b50318c466d8dc38323601ae8b355b8/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset003.png)

4\. In the `Choose Your data Connection` page click the **New Connection...** button. *This step will display the Add Connection dialog.*![WinForms RadGridView New Connection](https://www.telerik.com/products/winforms/documentation/assets/40c727f827c2502d2f63d3d79c12e47c/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset004.png)

5\. In the `Add Connection` dialog click the **Change...** button. This step will display the `Change Data Source dialog`.

![WinForms RadGridView Change Data Source dialog](https://www.telerik.com/products/winforms/documentation/assets/7cac7dea2c5a48fa4fa7b71ee47501e7/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset005.png)

6\. Select the **Microsoft Access Database File** data source. Click the **OK** button to close the `Change Data Source` dialog.

![WinForms RadGridView Microsoft Access Database File](https://www.telerik.com/products/winforms/documentation/assets/d9e4b938d3c822d6662bb0f29db62670/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset006.png)

7\. The `Add Connection` dialog will appear. Click the Database File Name **Browse** button and locate the "NWind.mdb" file from the Telerik UI for WinForms directory in the "\Examples\DataSources" directory. Click the **OK** button to close the `Add Connection` dialog.

8\. In the `Choose Your Database Objects` page, select the **"Categories"** table. Click the **Finish** button to close the `Data Source Configuration Wizard`.

![WinForms RadGridView Categories Table](https://www.telerik.com/products/winforms/documentation/assets/1f58791368b46a9fe7c07ce24b524319/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset007.png)

9\. In the Visual Studio Properties window for the grid **DataSource** property select the **"Categories"** table. *This step will create DataSet, BindingSource and TableAdapter objects for the categories table.*

![WinForms RadGridView DataSet](https://www.telerik.com/products/winforms/documentation/assets/27f18ec72373952a511f06172bb7cc78/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset008.png)

10\. The project design should look something like the screenshot below. Note the new data components in the component tray under the design surface.

![WinForms RadGridView Data Components](https://www.telerik.com/products/winforms/documentation/assets/2b443c7d6af3056281bab9ea88cb1a9e/gridview-populating-with-data-tutorial-binding-to-datatable-or-dataset009.png)

11\. Replace the Form_Load event handler with the following code. *The "foreach" code iterates all the columns in the grid and calls BestFit() so that the columns will expand to show the data*.

```C#
private void TutorialBindingToDataTableOrDataSet_Load(object sender, EventArgs e)
{
    this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
    foreach (GridViewDataColumn column in radGridView1.Columns)
    {
        column.BestFit();
    }
}
```

```VB.NET
Private Sub TutorialBindingToDataTableOrDataSet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories)
    For Each column As GridViewDataColumn In RadGridView1.Columns
        column.BestFit()
    Next
End Sub
```

12\. Press **F5** to run the application.

## See Also

* [Bind to XML](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/bind-to-xml)

* [Bindable Types](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/bindable-types)

* [Binding to a Collection of Interfaces](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/binding-to-a-collection-of-interfaces)

* [Binding to Array and ArrayList](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/binding-to-array-and-arraylist)

* [Binding to BindingList](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/binding-to-bindinglist)

* [Binding to DataReader](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/binding-to-datareader)

* [Binding to EntityFramework using Database first approach](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/binding-to-entityframework-using-database-first-approach)

* [Binding to Generic Lists](https://www.telerik.com/products/winforms/documentation/controls/gridview/populating-with-data/binding-to-generic-lists)

* [How to Bind GridView to a Local SQL Server](https://www.telerik.com/products/winforms/documentation/knowledge-base/gridview-databinding-tutorial-sql-server)
