Learn how to display data from an Access Database using ADO.NET and a DataGrid, and also learn how we can use the DataGrid to add new data and edit & delete existing data. VB version.

In this tutorial, we will show how we can display data from an Access database in a DataGrid Control, using ADO.NET. We will also see how we can use the DataGrid to edit, delete and add records to the database. First, we start off by adding the DataGrid to our ASPX page:

Note: All the On “Event” Commands will be referenced in our code.

next, we add the code to read the data from the database:

The above piece of code simply reads the data from the database and binds it to the DataGrid. We can now add more functionality to the DataGrid by adding the Button Columns Add, Update and Cancel, as well as Delete. We do this by going into the Property Builder (Property Pages) and choosing these buttons from the Button Column list. First, we uncheck ‘Creat columns automatically at run time, and then we also add a Bound Column for each database column we want displayed by the DataGrid. For each of these Bound Column, we type the Header Text and the Data Field should correspond with the column ID in the Access database.

Once we have done this, we can add the code to edit and update the fields:

The entire code-behind will look something like this:

Download Source Files