Show All

Add information from a database to your web pages

With this step-by-step topic, you will learn how to integrate a database with a web site using the Database Results Wizard.

What you should know before you begin

About your database

About your server and client computers

You should know whether the server — the computer hosting the web site — has the required services. Your Internet service provider (ISP) or web administrator can tell you whether the server has these services installed.

You should know whether the client — your computer — has the following installed:

About your web site

To use the Database Results Wizard, you must first create (or open) a web site.

If you have a local web server, create or open your web site using HTTP (for example, http://localhost/web). If you don't have a local server, use C:/My Documents/My Webs, or another disk-based location.

Important   You can't test how your site displays database information on a disk-based web until you publish it to a server that meets the server requirements.

How to use the Database Results Wizard

Step 1 — Connect to a database

Before you can use the information in a database on your web pages, you must create a database connection. Step 1 of the Database Results Wizard is used to set up the connection. Once you set up a database connection, you can use it on any page in your web site.

If you're familiar with databases, you can set up a new connection. Otherwise, you can practice using the sample connection and database provided with Microsoft FrontPage.

Set up a new connection

  1. Make sure your insertion point is on a web page, then start the Database Results Wizard (on the Insert menu, point to Database, and then click Results).
  2. Click Use a new database connection, and then click Create.
  3. Click Add, and then type a name for the new database connection in the Name box.

    Note   If your database is password protected, click Advanced in the New Database Connection dialog box. Then, type your user name and password in the boxes.

  4. Under Type of connection, choose one of the following types of connections:

    A file or folder in the current web site

    A file-based connection to a database, such as a Microsoft Access or Microsoft Excel database, is located in the web site.

    1. Click File or folder in current web, and then click Browse.
    2. In the Files of type box, select the driver for the type of database you're connecting to.
    3. In the URL box, type the path to the file or folder containing the database, and then click OK. Or, use the Look in box and file list to navigate to the file or folder you want, and then double-click the file or folder in the list.
    4. Click OK to close the New Database Connection dialog box, and then click OK to close the Web Settings dialog box.

      Note   If you import an Access database into your web before running the Database Results Wizard, you are automatically asked to create a database connection to that database and to store it in the Fpdb folder.

A System Data Source Name (System DSN) on a web server

A System DSN is located on a web server. A System DSN can connect to an ODBC-compliant database (such as a Microsoft Access or Microsoft Excel database), or a database management system (such as Microsoft SQL Server).

Ask your web server administrator to create a System DSN if you need one defined.

  1. Click System data source on Web server, and then click Browse.

    The System Data Sources on Web Server dialog box is displayed. The list shows the System DSNs defined on the web server.

  2. Select the System DSN for the database you want to access, and then click OK.
  3. Click OK to close the New Database Connection dialog box, and then click OK to close the Web Settings dialog box.

A database server on a network

A database server is a computer dedicated solely to managing and maintaining large databases (such as Microsoft SQL Server). A network connection to a database server accesses this type of database.

  1. Click Network connection to database server, and then click Browse.
  2. In the Type of database driver box, select the type of database driver you want to use to connect to the database server.
  3. In the Server name box, type the URL of the network server containing the database you want to access.
  4. In the Database name box, type the name of the database, and then click OK.
  5. Click OK to close the next three dialog boxes.

A database using a custom definition

A custom connection uses a file or string that defines all the necessary information.

  1. Click Custom Definition, and then click Browse.
  2. In the Files of type box, select a File DSN, Universal Data Link (UDL) file, or edit a connection string:
  3. In the Database name box, type the name of the database, and then click OK. The database driver referred to by the File DSN or the connection string must be present on the web server for the connection to work properly.
  4. Click OK to close the next three dialog boxes.

Use a sample connection and database

The sample database provided by Microsoft FrontPage is a Microsoft Access database. If you use this database, the wizard automatically imports the database file fpnwind.mdb into the Fpdb folder of your web site. If you have Microsoft Access 2000 or later, you can open this file to view its contents. Viewing the contents will help you understand the other options in the wizard.

  1. Make sure your insertion point is on a web page. Start the Database Results Wizard (on the Insert menu, point to Database, and then click Results).
  2. In Step 1 of wizard, click Use a sample database connection (Northwind).

Step 2 — Choose a record source

After you have created the database connection, Step 2 of the Database Results Wizard displays the record sources (the names of the tables and views) in the database. Choose the source you want to use.

  1. In Step 2 of the wizard, click Record source.
  2. From the drop-down list, click the table or view that contains the information you want to display.

Step 3 — Determine how records will display

Step 3 of the wizard lets you determine how you want the records in the database to display. In this step of the wizard:

Step 4 — Choose formatting options for database results

In Step 4 of the wizard you determine how you want to format the database results. You can choose to format the information in a table, a list, or a drop-down list.

Format database results as a table

In Step 4 of the wizard, in the Choose formatting options for the records returned by the query list, click Table - one record per row.

Specify the additional table formatting you want for the database results region:

Format database results as a list

In Step 4 of the wizard, in the Choose formatting options for the records returned by the query list, click List - one field per item.

Specify any additional list formatting options you want, as follows:

Format database results as a drop-down list

  1. In Step 4 of the wizard, in the Choose formatting options for the records returned by the query list, click Drop-down list - one record per item.
  2. Under Display values from this field, select the field you want to use for the choices that will be displayed to the site visitor.
  3. In the Submit values from this field box, select the field to be submitted if the drop-down list is inside a form. You can choose the same field you selected in the previous step, or choose a different one.

Step 5 — Show records together or in groups, and finish the wizard

The final step of the wizard lets you determine whether to show all records together or separate them into smaller groups. If you choose to display records in smaller groups, Microsoft FrontPage automatically adds navigation controls to let site visitors navigate through the groups of records.

Note   The option to Split records into groups is unavailable if you select Drop-down list in Step 4 of the wizard.

  1. In Step 5 of the wizard, choose one of the following grouping options:

    Display records in one list or table on a page

    Click Display all records together.

    Divide records into smaller groups

    Click Split records into groups, then type the number of records you want to include in each group.

  2. Click Finish to end the wizard. The web page will display the database results region you created using the wizard.

Save and test your web site

Once you have completed the wizard, a Database Results region is inserted on the web page. To view how the data will look when your web is browsed, you must save the page as an Active Server Page (ASP) and browse the site to view database results.

  1. On the File menu, click Save as. Notice that the Save as type box indicates Active Server Pages. Enter a name for the file in the File Name box and ensure that the file extension is .asp.
  2. Click Preview in Browser Preview in Browser button to view the site.

Note   If you created a disk-based web site, you must first publish your site to a web server that meets the server requirements.