Using an AccessDataSource Control in Visual Studio
Here are the steps for using an AccessDataSource control
in Visual Studio
Open Visual Studio. Create an ASP.Net Web Application.
In the Solution Explorer, go to the Design Window of the
Default.aspx file.
Drag an AccessDataSource from the Toolbox
onto the form. Use the Properties Window
to change its ID to ads.
Click on the ads control. Click on the right arrow and click on
Configure DataSource.
In the Configure Data Source Dialog, enter the name of the Access
database. Click Next.
Check the * textbox. The SQL statement should be
Select * FROM [Persons]. Click Next.
Click Test Query. The entire Persons table should be displayed.
Click Finish.
Drag a GridView control from the Toolbox onto the form.
Use the Properties Window to change its ID to gvPersons.
Click on the gvPersons control. Click on the right arrow.
Click on the Choose Data Source drop down list and select ads.
Run the application. The Persons table should be displayed.
Place TextBox, DropDownList, and Button controls on the form.
Use the Properties Window to change their IDs to
txtAge, ddlGender, and btnButton, respectively.
Use the Properties Window to add items to the Items property
of ddlGender. Add two Items with Text=Female,Value=F; Text=Male,
Value=M.
Double click on btnButton to produce the event handler
btnButton_Click in the code-behind window. Add these lines of C# code
to this event handler
ads.SelectCommand = SELECT * FROM Persons +
WHERE Age < + txtAge.Text + AND +
Gender = ' + ddlGender.SelectedValue + ';;
Run the application.
Move the btnSubmit_Click event handler to the .aspx file.
change protected to public and place the event handler to within
<script runat=server> </script> tags.
You can now change the name of the .aspx file from Default.aspx
to example.aspx (or some other name) and upload it to ectweb2.