Expression Answers

News, Tutorials and Forums dedicated to Microsoft Expression Suite.
Welcome to      Expression Answers Sign in | Join | Help
in Search

Expression Web

Using Expression Web to connect to an Access Database

          Watch the tutorial in Flash here

It's easy to use Expression Web to connect to an Access database.  This tutorial connects to the "Northwind" Database which is the sample database that comes with Microsoft Access.  If you don't have this database installed, you can download it from Microsoft's website here: 

With a website open in Expression Web, create a new ASPX page and give it name and save it.  (You won't be able to define a datasource until the page is saved).   From the Toolbox on the right, find the AccessDataSource control and drag and drop it to your page.

AccessDataSource

 After dropping the AccessDataSource control, click the "Configure Data Source" link.  From the resulting window, Browse to find your Access Database.  In this example we browse to the "_private" directory and select "Nwind.mdb".

Browse to find the Access Database

After selecting the Access database by clicking the Open button shown above, click the Next button on the next display.  The "Configure the Select Statement" will now be shown.  This page is where you select which data you would like to use from the database.  In this example we will retrieve data from the "Customers" table so we will select the "Specify columns from a table or view" radio button (which is selected by default), and for the next option, "Name", we will choose the dropdown arrow and select "Employees".   

The various data fields for "Employees" should now be shown.  You can select the asterisk to get all of the data fields, or pick the fields that you would like to display in your table on your web page.  In this example we will select LastName, FirstName, Title, Address, and City (as shown below). 

Selecting your data fields

After selecting the data fields that you wish to display, click the Next button.  On the resulting window, click the "Test Query" to verify that the selected data fields return.

Testing the Query

Click the "Finish" button. Now, go back to the Toolbox, and in the "Data" section find the "GridView" control and drag and drop this to your webpage.  Your page should now look like the below image:

GridView drop

On the "Choose Data Source" option, click the down arrow and choose "AccessDataSource1" (which is the Access data source that we just defined in the previous step).  Your GridView control should now show the column headers for the data fields that you have selected to display. 

GridView with column headers

The page is now ready, so save the file and to preview it in a browser, choose File, Preview in Browser, and choose and browser.  The aspx page should look like below:

Browser preview

Expression Web can make the table more functional and easy to read; just click on the top right corner of the table to bring back the GridView tasks:

GridView Tasks

The "AutoFormat" menu allows you to select a table "theme".  In this example we've chosen the "Slate" theme.  The checkboxes in the GridView Tasks allow paging, sorting and selection of the record.  In this example we've selected "Enable Sorting" which makes each column sortable by clicking on the column header.  The final result of the table is shown below.

Final result

Published Monday, July 16, 2007 10:31 PM by DougC
Filed under:

Comments

No Comments
Anonymous comments are disabled
Powered by Community Server, by Telligent Systems