FrontPage 97 allows you to integrate with ODBC-compliant databases and integrate with your database files dynamically. Using FrontPage and Microsoft Internet Information Server or the Microsoft Personal Web Server, corporations can create forms that retrieve ordering information, survey information, customer feedback, project data, and more. The FrontPage Database Connector Wizard can help generate Internet Database Connector files, which allow Web pages to interface with the data on the corporation's Internet or intranet site. This chapter gives an overview of creating Internet Database Connector files and query results files.
When you design a form for use with the Internet Database Connector Wizard, you design it like any other. You should note the names of the form fields that you use in the form, however, because you'll need to use the same form field names when you create your IDC file with the Database Connector Wizard.
The form shown in Figure 16.1 will be used with the Database Connector Wizard. As you can see, the form isn't any different than the others you see in FrontPage. The form contains the following field names (from top to bottom): FirstName, LastName, Your E-Mail, Your Web Site URL, and Add your Comments. These field names will be referenced in the database results file and when using the Database Connector Wizard. If the data entered into your form must meet certain criteria, you can use form field validation to assign the criteria to the form field.
Figure 16.1 : Any form can be used with the Internet Database Connector.
After you design your form and configure the database results file, you generate an IDC file using the Database Connector Wizard. You assign this IDC file as a form handler in the Form Properties dialog box as shown in Figure 16.2.
In order for the form shown in Figure 16.1 to work correctly with the IDC file, it needs a special kind of results file. Here's where the procedures start to differ from forms used with the standard FrontPage form handling bots discussed in Chapter 22, "Runtime Bots-The Heartbeat of FrontPage Forms." The results file used with IDC-related forms must be saved to your web with an .htx extension. In addition, you enter SQL query data into the page with commands found in the Edit | Database menu of the FrontPage Editor. An example of a simple database results file is shown in Figure 16.3.
You begin to create a database results file as follows:
A detail section is HTML that is returned once for each record that is returned as a result of a database query. A detail section is marked by a pair of detail section markers, which you can see at the beginning and end of the data contained in the second cell of the table shown in Figure 16.4. Detail sections can contain other database elements such as database column values, IDC parameters, and if-then-else statements. To create a detail section, follow these steps:
Database Column Values insert values from one column in a database record into a database results file. The column names must agree with the columns set in your ODBC database table. In addition, they must be contained within a detail section. Figure 16.4 shows several database column value entries in the database results file. Database column values are surrounded by brackets and percentage signs when they appear on your page (example: <%FirstName%>).
To display a database record column value, follow these steps:
An IDC parameter value can be the name of one of the form fields used to compose a database query, or a default parameter specified in an IDC file. For example, the results file shown in Figure 16.6 returns the first name and last name of a single entry in a guest book.
Figure 16.6 : IDC parameters are added to the page in the IDC Parameter Value dialog box.
To display an IDC parameter, follow these steps:
You use an If-Then conditional section to display a portion of an .htx file if a Boolean expression is true. The FrontPage Editor marks the beginning of an If-Then conditional statement with an If-Then condition marker, and its end with an End condition marker. You can add any content within the section after it is defined. In the example shown in Figure 16.3, the If-Then markers surround the text that reads Thanks for signing the guest book!.
To create an If-Then conditional section, follow these steps:
You add an Else conditional section to display a section of the page when your If-Then conditional section (described in the previous task) equates to false. In Figure 16.3, the query results file returns the FirstName and LastName IDC parameters if a user is already registered in the database. All content between the Else marker and the End Condition marker is displayed when the condition is false.
You can only add an Else conditional section inside an If-Then conditional section. To add an Else conditional section, follow these steps:
When you delete database directives, all IDC parameter values, database column values, beginning and ending markers for detail sections, and beginning and ending markers for conditional statements are removed.
To remove database directives from a database results file, follow these steps:
Before you use the Database Connector Wizard, your server administrator will need to set up and configure the ODBC data source file on your server. Setup will vary depending on the ODBC driver that you use. To use the Database Connector Wizard, you'll need to know the name of the ODBC data source, a username and password required to log on to the data source (optional), and the name of a query results template that will be used to handle the data received from the query.
If you are using Windows 95, the Internet Database Connector requires the use of the Microsoft Personal Web Server, furnished with the FrontPage Bonus Pack. Do not install the Microsoft Personal Web Server if you are running Windows NT.
An Internet Database Connector (IDC) file works with Open Database Connectivity (ODBC) compliant databases. ODBC is a standard that is used to access different database systems. Structured Query Language (SQL) queries are used to communicate with any ODBC compliant database that is accessible from the Web server. Using these queries, you can extract information from the database. The connection information is specified in the IDC file.
The IDC file also specifies a query results template file in your FrontPage web, which traditionally use an .htx extension. The .htx file is a Web page that contains special parameters, variables, and control information that relate to your SQL database queries. IDC files contain the following types of information, which control the data that is displayed at runtime:
How to connect to the database.
The SQL query to execute.
The name of the .htx file used to process and display the results of the query.
Database record column values.
IDC Parameter values.
If-Then-Else statements.
You use the Internet Database Connector Wizard to create an Internet Database Connector (IDC) file. The SQL query and database connection information is contained in an IDC file. The IDC parameters that you define in the Database Connector Wizard should agree with those that appear on the form you design. In the case of the example covered in this chapter, use the same names as the form shown in Figure 16.1.
To create an IDC file, follow these steps:
NOTE |
You can also start the Database Connector Wizard by clicking the Database Connector Wizard button on the Advanced toolbar. |
In the first screen of the Database Connector Wizard, shown in Figure 16.8, you specify your ODBC data source, a username and password (if required), optional advanced options, and the name of the query results template that will be located in your web. To complete the screen, follow these steps:
In the second screen of the Internet Database Connector Wizard, shown in Figure 16.9, you enter your SQL queries. The query is entered into the data field provided in the dialog box. Where a database parameter name is required, insert the parameter name with the Insert Parameter button.
To insert queries, follow these steps:
In the third screen of the Internet Database Connector Wizard, you specify default parameter values. These are parameter values that will always be used whenever the SQL query is run. These parameters are combined with those entered by the user and passed to the form handler. If a user follows a link to the IDC file, only these parameters are used.
To specify default parameter values:
To modify a default parameter value, highlight the parameter you want to modify, and click the Modify button. The Modify Parameter dialog box appears. Edit the Parameter name or Default value and choose OK. You return to the Internet Database Connector Wizard.
To remove a default parameter value, highlight the default parameter name you want to remove, and click the Remove button. The parameter is removed from the list.
Before you exit the Internet Database Connector Wizard, the Current Web dialog box shown in Figure 16.12 appears. You are prompted to save your IDC file into the current web. You must save the page into a directory into which executable scripts can be stored.
To save your .htx file, follow these steps:
NOTE |
To determine whether a folder can hold executable scripts, open the FrontPage Explorer. Select Folder View. Select a folder and choose Edit | Properties. The Properties dialog box for the folder appears as shown in Figure 16.13. If the folder is marked Allow scripts or programs to be run, it can hold executable scripts. |
Advanced options in the Internet Database Connector Wizard are optional, and require familiarity with ODBC system administration procedures. Consult your ODBC driver documentation for further recommendations on settings to be used here. You can access the Advanced Options settings from the first screen in the Database Connector Wizard, by clicking the Advanced Options button.
Query options allow you to specify settings for SQL escape sequence scanning, cached results expiration times, query timeouts, transaction isolations, and content type. If your ODBC content also requires foreign character translations, you can specify the translation files here.
To specify advanced query options, select the Query tab in the Advanced Options dialog box, check one or more of the following options, and enter values in the respective data entry fields:
Do not scan for SQL escape sequences. Select this option to prevent the ODBC driver from scanning SQL strings for escape clauses. The statements will be sent directly to the data source instead. If your SQL statement does not contain any ODBC escape clauses (enclosed by curly braces), then you will see a small performance gain if you check this option.
Cached results expiration time (sec). Enter the number of seconds to wait before refreshing a cached output page. This is used when you want to force another query of the database after a certain period of time. IDC only caches pages when this field is used.
Query Timeout (sec). Check this option to set the number of seconds to wait for an SQL statement to execute before the query is canceled. If the timeout value exceeds the maximum timeout setting in the data source, the driver substitutes the maximum value. If the query timeout value is less than the minimum timeout setting in the data source, the driver substitutes the minimum value.
Transaction isolation. Check this option to set the transaction isolation level. This setting allows you to retrieve data that has not been committed to the database by other transactions.
Content type. Check this option to specify the type of content that will be contained in the POST request. The default is text/html.
HTML Translation File. Check this option if your database is in a language other than English. A translation file maps each special character in the following format: value=string<CR>, where value is an international character, and string is the HTML translation code. Enter the full path to the file that maps non-English characters so that Web browsers can display them properly in HTML format.
ODBC Translation DLL. Check this option to enter the name of a DLL that contains the functions SQLDriverToDataSource and SQLDataSourceToDriver. These functions are used to perform tasks such as character set translation.
ODBC Translation Option. Check this option to specify a value that controls translation functionality, specific to the translation DLL being used. You will need to consult the documentation for the ODBC driver and translation DLL for details.
Connection options allow you to enable read-only access, to specify a logging file of OBDC calls, to turn ODBC connection pooling on or off, to specify an SQL logon timeout value, and to specify a network packet size.
To specify advanced connection options, select the Connection tab in the Database Connector Wizard's Advanced Options dialog box. Choose one or more of the following options, and enter values in their respective data entry fields.
Read-only access. Checking this option will prevent the IDC connection from changing the data in the data source that it connects to.
Enable logging of ODBC calls. Select this option to log each function call made by the ODBC driver. To use a logging file other than a default name of sql.log, enter a name in the Log File field.
ODBC connection pooling. Select this option and choose On to keep the connection to the data source open in between data requests.
SQL logon timeout (sec). Check this option to specify the number of seconds to wait for a logon request before disconnecting, and enter a value in seconds in the timeout field. If you enter a value of zero, the timeout is disabled and waits indefinitely.
Network packet size (bytes). Check this option to specify the network packet size. This option is not supported by some data sources.
Use the Limits tab in the Advanced Options dialog box, shown in Figure 16.16, to specify advanced settings for ODBC driver limits and IDC limits.
To specify ODBC driver limits options, use the ODBC Driver Limits section in the Limits tab.
Maximum field length (bytes). Check this option to specify the maximum amount of data returned from a character or binary column. This should only be used when the data source in a multiple-tier driver can implement it.
Maximum number of data rows returned. Check this option to specify the maximum number of rows returned for a SELECT statement. All rows are returned by default.
Use the IDC Limits section in the Limits tab to specify the following Internet Database Connector options:
Maximum displayed field length. Check this option to specify the maximum buffer space allocated per field by the IDC file. Any characters beyond this space are truncated. The default value is 8192 bytes.
Maximum number of data rows fetched. Check this option to limit the number of records returned from one query. No value is specified by default, so a query can return up to four billion records.
To specify driver-specific options, use the Driver Specific tab in the Advanced Options dialog box of the Database Connector Wizard. You will need to refer to your ODBC driver documentation for descriptions of available options.
To specify driver-specific options, follow these steps:
Using FrontPage and the Internet Information Server or Microsoft Personal Web Server, you can create dynamic interfaces with any ODBC-compliant database. Your data can be maintained and updated in real time over the Internet. It can be used to track orders, keep a record of all the people that have visited your Web site, maintain project records, and more. You can use FrontPage to develop the files and pages required to process the data dynamically.
If you're the type of person who likes to get into the heart of the matter, the next chapter shows you how to add your own HTML code into your FrontPage Web pages. For more topics that relate to database connectivity, refer to the following chapters:
Q: | Can I just enter the Database Column Values and IDC Parameter Values on my page surrounded by brackets and percentage signs? |
A: | No, you must use the Edit | Database Commands to do so. Special codes are added to your HTML source code that define these items as database column values and IDC parameter values. |