Working with the Database Interface Wizard

In the previous section, you learned how to display existing records in a database using FrontPage. FrontPage also offers the ability to edit, add, and delete records from a database using the Database Interface Wizard. The Database Interface Wizard will add all the pages necessary for you to display records from your data source, edit those records, add new records, and delete existing records. It will even provide a password protected editing interface so that only those users you choose can edit your data source.

The Database Interface Wizard is a Web site wizard. Therefore, you can either create a new Web site with the Database Interface Wizard or you can add the Database Interface Wizard to an existing Web site. It is usually most convenient to add it to an existing Web site because you will then have the option to use an existing database connection. Let's add a Database Interface Wizard to your existing Web site and create some pages that will allow you to edit your database.

Creating a Site with the Database Interface Wizard

To insert the Database Interface Wizard, follow these steps:

  1. Select File, New and click the More Web Site Templates link in the New task pane.

  2. Select the Database Interface Wizard template.

  3. Check the Add to Current Web Site check box.

  4. Click OK to display the Database Interface Wizard, as shown in Figure 37.23.

    Figure 37.23. The Database Interface Wizard makes it easy to create pages to edit your database.

    graphics/37fig23.jpg

Choosing ASP or ASP.NET

As with the Database Results Wizard, you can choose between ASP and ASP.NET. Choose ASP and select the Use an Existing Database Connection option. Make sure that the Sample database connection is selected and click Next to proceed to step 2 of the wizard.

graphics/troubleshooting_icon.jpg

If the Use an Existing Database Connection option is disabled, see "Use an Existing Database Connection Is Disabled" in the "Troubleshooting" section of this chapter.


Configuring the Record Source

In step 2, select Employees from the dropdown so that the Database Interface Wizard will connect to the Employees table just as you did with the Database Results Wizard. FrontPage chooses a location for your Database Interface Wizard files using the <connection_name>_interface/<record_source> naming convention. You can change this if you want, but for now, leave it as the default and click Next.

TIP

The Database Interface Wizard places all of its files in the folder specified in step 2. If you decide to remove the Database Interface Wizard from your Web site, simply delete that folder and it's gone.


Formatting Your Data

Step 3 of the Database Interface Wizard is where you choose the order of the columns in your record source and how they are configured. The EmployeeID field has an asterisk next to it to indicate that it is the primary key, a field in the database that must be unique for every record. If you leave it configured as is, when a user enters a new employee, she will have to enter an employee ID for that person. It would be preferable if the number could be generated automatically so that the user of your page doesn't have to worry about entering a number that already exists. To set that up, do the following:

  1. Select the EmployeeID field and click Modify.

  2. In the Column type dropdown, select Autonumber.

  3. Click OK.

The EmployeeID field now shows a column type of Autonumber and the form field type is empty, as shown in Figure 37.24. This will cause the Microsoft Access database to automatically assign the next available employee ID to newly entered employees. Because the form field type is empty, the EmployeeID field will not display to users of your site, which is exactly the way it should be. Click Next to move to step 4.

Figure 37.24. The EmployeeID field has been modified so that it is an autonumbered field.

graphics/37fig24.gif

Choosing the Pages for Your Site

In step 4 of the Database Interface Wizard, you choose what pages you want the Database Interface Wizard to generate for you, as shown in Figure 37.25.

  • Results Page The page that displays the contents of your database

  • Submission Form The form that allows for the creation of new records for your database

  • Database Editor A series of Web pages that allow for complete administration of your database from your Web browser

Figure 37.25. The Database Interface Wizard allows you to choose which pages to include.

graphics/37fig25.jpg

Select all three check boxes and click Next to move to step 5.

Specifying a Username and Password

In step 5, you can specify a username and password that will be required to access your database editor. If you password protect your editor, the only page that people can view without the correct username and password is the results page, results_page.asp. Any editing, deletion, or addition of records requires the correct username and password. Enter the username and password of your choice and then click Next and Finish to insert your Database Interface Wizard pages.

To see how to use the Database Interface Wizard's password protection on any page you prefer, see "Front and Center: Password Protecting Pages of Your Choice," p. 732.


Content Added by the Database Interface Wizard

After the Database Interface Wizard has finished adding pages to your site, you will have a new folder named whatever you specified in step 2 of the wizard. Inside that folder, you will have folders and files that will differ, depending on which pages you chose to have inserted, as shown in Figure 37.26.

Figure 37.26. The Database Interface Wizard inserts many pages in to your site, depending on the options chosen in step 4.

graphics/37fig26.jpg

CAUTION

Even though the Database Interface Wizard uses Database Results regions, don't ever edit the pages with the Database Results Wizard. If you do, it will break the functionality of the Database Interface Wizard pages.


Assuming that you checked all three check boxes in step 4 of the Database Interface Wizard, the following pages will be added to your site:

  • results_page.asp Displays all the records in your database, much like the Database Results Wizard page that you created earlier. This is the only page that is not protected by a password if you chose to have your editor password protected in step 5 of the wizard.

  • confirm.asp A confirmation page that is displayed after a new record is added to the database.

  • database_editor.asp A frames page that displays the database editor.

  • delete.asp Appears in the bottom frame of database_editor.asp when you are deleting records from the database.

  • detail.asp Displays in the bottom frame of database_editor.asp when a record is selected from the top frame by clicking an employee ID.

  • edit.asp Appears in the bottom frame of database_editor.asp and allows for editing of records.

  • list.asp Appear in the top frame of database_editor.asp.

  • login.asa This page is included in each ASP page of the database editor when they are protected with a password. It contains the username and password that you configured for the database editor.

  • login.asp The login page for the database editor if it is protected with a password. If a user requests a page in the editor without logging in, she is automatically redirected to this page.

  • Login_Validate.asp Contains ASP code that validates the username and password entered in the login page. If the login entered is correct, the user is taken to either the database_editor.asp page or the page she originally requested.

  • new.asp Appears in the bottom frame of database_editor.asp when a new record is being added.

  • submission_form.asp A standalone (nonframed) version of new.asp that appears whenever the Submission Form link is clicked from database_editor.asp.

  • update.asp Contains the ASP code necessary to update a record that is being edited.

The entry point for a Database Interface Wizard site is usually results_page.asp. From there, a user can access all the other pages in the editor.

TIP

The Database Interface Wizard can also create a new database in your Web site. In step 1 of the Database Interface Wizard, select the Create a New Microsoft Access Database Within your Web Site radio button to have a new database created for you in the fpdb folder of your Web site.


Using the Database Interface Pages

Now you can check out your database editor in action. Browse to the results_page.asp that the Database Interface Wizard created, and you should see a page similar to the one shown in Figure 37.27. In the upper-right corner of this page are links to the Submission Form and the Database Editor. The Submission Form allows you to add new records to the database. You can also add new records from the Database Editor in addition to editing and deleting existing records.

Figure 37.27. The Results Page generated by the Database Interface Wizard contains links that will allow you to edit your database.

graphics/37fig27.gif

Click the Database Editor link. You should be prompted to log in as shown in Figure 37.28. Enter your username and password and click Login to log in to the Database Editor. When the Database Editor appears (see Figure 37.29), you can add a new record by clicking the Add New Record button, delete one or more records by selecting them and clicking the Delete Selected Records button, or edit a record by selecting that record and then clicking the Edit button at the bottom of the page.

Figure 37.28. The login page protects access to the Database Editor.

graphics/37fig28.gif

Figure 37.29. The Database Editor provides all the functions necessary to maintain the records in your database.

graphics/37fig29.gif

Click the Add New Record button. Fill in information for yourself and click the OK button to add yourself to the database. After you have been added, click the next page button (the > button) at the bottom of the top frame to go to the next page. Your record will appear last in the list (see Figure 37.30) because the list is ordered by the EmployeeID field, and since you are the last employee entered in the database, you have the highest employee number.

Figure 37.30. A new record has been added with the information entered.

graphics/37fig30.gif

Click your employee number to display details on yourself. The bottom frame will refresh with the details on your record. At the bottom of the details page are Edit button and Delete buttons. From here, you can edit or delete your record. You can also remove one or more records by checking the box next to the record in the top frame and clicking the Delete Selected Records button.

As you can see, building a full-featured database editing system is very easy with the Database Interface Wizard, and you can do it all without writing a single line of code.



Special Edition Using Microsoft Office FrontPage 2003
Special Edition Using Microsoft Office FrontPage 2003
ISBN: 0789729547
EAN: 2147483647
Year: 2003
Pages: 443

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net