AccessDataSource
The AccessDataSource controls facilitate retrieval of data from MS Access Databases (.mdb). These controls acquire all the properties of the SQLDataSource control. The ConnectionString property is replaced by the DataFile property in order to handle Microsoft Access Databases. We have to use System.Data.OleDb provider to connect to the Access Database using the Microsoft.Jet.OLEDB. 4.0 OLE DB Provider.
Creating AccessDataSource in ASp.net
-
Create a Database Emp.mdb and a table Employee

-
The file can be stored in the App_Data folder to keep the database private. Asp.net will not allow files in the App_Data folder to be returned directly.
-
From the Toolbox you will find the AccessDataSource under the Data Section. Drag and drop the control to the form.

-
Select the property of the AccessDataSource Control and set the DataFile to App_Data\emp.mdb file.,

-
Place the SelectQuery from the property window and type “SELECT ID, EmpName, Age, Manager, Address FROM Employee” in the Select Command Textbox of the Command and Parameter Editor window; then click ok. (Refer to the diagram below.)

-
Open the Source window of your aspx page; you will see the following properties set for the AccessDataSource control.
<asp:accessdatasource datafile="~/App_Data/Emp.mdb" id="AccessDataSource1" runat="server" selectcommand="SELECT ID, EmpName, Age, Manager, Address FROM Employee">
</asp:accessdatasource>
We have completed the selection of the data from the Access database.
Now we have to display the data using GridView control.
GridView
The GridView control is used to display the data in a table. We can display the data in the GridView control using Data Source controls such as AccessDataSource and SqlDataSource.
-
Drag and drop the GridView control from the Data Section of the Toolbox.

-
Now open the property window of the Gridview control. There is a property called DataSourceId used to set the DataSource. DataSourceId will have a dropdown list.
-
When you select the dropdown list, AccessDataSource1 will be displayed. Select AccessDataSource1 control from the list.

Now everything is set. Run your application. The Employee records will be displayed in the Grid View.
