The following steps will help you to conenct to a MS Access Database
from your ASP.NET web form.
Step 1 :
Create an Asp.Net Web Application
select ASP.NET Web Application
In the Design View of the form , from the WebForms ToolBox
Drag and Drop a Button
Drag and Drop a DataGrid
From the Data ToolBox,
Drag and Drop a OleDBDataAdapter
Now the Data Adapter Configuration Wizard Will Appear
Click ON Next
Click On New Connection
In the Data Link Properties Form , Click On Provider
Choose Microsoft Jet 4.0 OLE DB Provider(Or 3.51 OLE DB Provider, depending on MSAccess installed on your machine)
Click On Next
In the resulting window, Enter the complete path to your Local
Access DataBase (For ex:C:\SampleDB\BooksDb.mdb).
You can also browse the .mdb file using the Button next to the Text Box.
Click on Test Connection to make sure that the DB exists and that you are able to connect to the Database.
Dont forget to enter the password information if you are using a password for your database.
Click on Ok.
Click on Next in the Data Adapter Configuration Wizard
Make sure the "Use Sql Statements" Radio Button is Checked and Click Next
Enter the SQL query in the Resulting window (For ex: Select * from Books)
(Or You can use the Query Builder to build your queries)
Now you are all set to retreive the data from the DataBase you specified.
Now In the Button Click Event, include the following Statements
Compile and run your program. If you click the Button, you can see the Datagrid is being populated by the data from the DataBase.
DataSet dataset=new DataSet();