by Jeff Thurston
There is little doubt that the Internet will continue to grow in terms of the number of users, the number of sites, the volume of content, and accessibility. Bandwidth problems that once precluded the use of large volumes of information and dazzling graphics are rapidly disappearing. This is resulting in World Wide Web (WWW) site publishers becoming increasingly creative, thereby raising expectations of what a useful site should be. Users are no longer content to view sites with static content, and unless current information is presented, chances are they will never make a second visit.
Similarly, the intranet continues to become more prevalent. Companies of all sizes are using intranets to increase accessibility to key corporate data. Policy manuals, company telephone listings, product information, benefits information, and special-events calendars are just some of the myriad uses for this growing technology.
Most important of all, new levels of functionality are enabling WWW site publishers to reach a growing audience. Unlike traditional media, such as television, newspapers, magazines, and billboards, the Internet and intranets are providing a way for publishers to collect as well as distribute information. At a minimum, WWW site publishers can collect information showing interests based upon the number of times a particular page is viewed. At the other end of the spectrum, such information as name, location, income, interests, and various other demographic data can be retrieved and stored for later use.
Regardless of its use, it is becoming increasingly necessary to include dynamic and interactive content in any successful WWW site. This need will only grow as Internet technologies penetrate homes and businesses around the globe.
Most WWW publishers will agree that the need for interactive and dynamic content is a critical component of any good site. Until recently however, the creation and maintenance of sites containing these components required considerable effort on the part of developers. Solutions that did exist usually exhibited poor response times, poor quality, or both.
The tools landscape is rapidly changing, however. New tools are appearing on the market nearly each day, and the race to be the number one tool provider is yielding tools of exceptional value and functionality.
As a leader in Internet technology, Microsoft has released two tools that provide developers with the ability to quickly create interactive and dynamic Web sites. These tools are the Internet Database Connector (IDC) and dbWeb. This chapter provides a brief overview of both tools.
It has not been so long ago that most WWW sites consisted primarily of text documents that included embedded links to other text documents or simple graphics. Users were able to navigate these sites by selecting link indicators, thereby activating a link and causing the target document to subsequently be displayed. Although some might argue that this is interactive, it does not begin to compare with the level of interaction that is possible today.
For the most part, the WWW is not based upon the concept of a session. Users move from document to document with little regard to where they've been and, more importantly, leave little or no trace of who they are. A request for a document usually consists of a connection as an anonymous user, a download of one or more documents, and finally a disconnection from a server.
With current technology, however, it is possible to simulate a session to provide a personalized version of a single document or an entire Web site. Such sites as the Microsoft Network (http://www.msn.com) and the Wall Street Journal Interactive Edition (http://www.wsj.com) enable users to maintain a personalized home page. Each time a user visits one's home page, content is presented based upon information the user has provided during a registration process. For example, if the user indicated an interest in baseball, relevant information about baseball would be presented each time the page is accessed.
Although the content may be valuable to the user making the request, the registration process also provides the WWW publisher with an opportunity to collect useful information about the user. Such information as name, age, income, and interests can be collected and stored in a database. Later, that information can be used to provide valuable information about the types of people who visit the WWW site.
Maintenance represents a major portion of the efforts required by a WWW site. Some companies have armies of Hypertext Markup Language (HTML) developers, graphic artists, content authors, hardware engineers, network engineers, and so on. Others, however, may rely on a single person for all new development and maintenance. Regardless of the situation, it is important to use every tool available to provide the most value with the least drain on resources and budget.
Dynamic content is generated as it is requested, usually based upon specific criteria provided by the user. In contrast, static content is created and stored; the same content is presented to the user each time it is requested. Therefore, the use of dynamic content can significantly increase the volume of information available to your users without significant effort required of the WWW team.
As an example, consider the company wanting to publish product information on its WWW site. A catalog metaphor, complete with company logo in the upper-left corner is decided upon. The initial creation of these pages is rather simple: Key in the text and a few headings, include the graphic, add some footer information, such as the copyright notice, and save.
Several months later, the company decides to update its logo. Maybe the new logo now sports a drop shadow and is nearly the same size; maybe it is a different shape entirely. Regardless, each HTML document must now be updated with the new logo, possibly requiring reformatting to maintain a balanced, professional appearance.
Using dynamic content tools such as Internet Database Connector (IDC) or dbWeb, document templates can be used to present such data in a consistent manner. The template would likely include the graphic, basic formatting attributes, such as background graphic or watermark graphic, and the copyright information. This template would then be used by dbWeb or IDC to generate HTML documents dynamically as users made specific requests. More importantly, when changes to such items as logos become necessary, only the templates need updating.
It does not take long to understand the power provided by these tools. Even if your site has only a handful of similar pages, it may be advantageous to use either IDC or dbWeb to generate dynamic content.
The two tools provided by MicrosoftñInternet Database Connector (IDC) and dbWebñease both the creation and maintenance of interactive and dynamic WWW sites. Both of these tools are based upon Microsoft's Internet Server Application Programming Interface, more commonly referred to as ISAPI. The primary difference is that the IDC tool provides a facility with which the developer is able to create and use custom SQL and formatting via HTML-based templates. These templates contain tags recognizedby IDC to generate the actual HTML document sent to the user.
In contrast, the dbWeb tool uses wizard technology and a full-featured Graphical User Interface (GUI) to enable the developer to quickly create dynamic content by selecting options and providing key values. The option settings and key values are stored in a central Microsoft Access (MDB) database.
The tradeoffs these tools represent are no different than the vast majority of development tools. IDC requires more effort but provides more flexibility. On the other hand, dbWeb is simpler to use but offers limited functionality with which to create content. Although it can be argued that dbWeb enables content to be created quickly, a basic understanding of HTML and SQL yields results with IDC just as quickly in most cases.
For most users, the deciding factor may be the skills required by the tool. A good understanding of both SQL and HTML are required in order to effectively use IDC. SQL statements must be built and inserted into IDC query files. Resultsets are then presented based upon IDC tags embedded into a standard HTML document.
No such knowledge is required to use dbWeb. Queries are built using list boxes and combo boxes. Similarly, output options are set using user-friendly dialog boxes. Only when more complex queries or output are required does the developer need an understanding of HTML keywords or special formatting.
Major Features of dbWeb and Internet Database Connector
As shown in Table 24.1, these two tools have much in common. They both use ODBC for database connectivity and both are built upon ISAPI. Their differences, however, are significant. IDC is merely a filter that replaces tags embedded within an HTML document with data values; whereas dbWeb is a full-featured, self-contained application. While dbWeb is capable of both creating and serving dynamic content, IDC is capable only of serving it. Creation of the files required by IDC to generate dynamic content demands the use of a tool such as Microsoft FrontPage, or at the very least a text editor. The tool you use will depend upon the complexity with which you intend to present your content, and the skills you possess in HTML and SQL.
Feature | IDC | dbWeb |
Template creation | Requiresother tools | Schema Wizard/SchemaEditor |
Template storage | *.IDC files | dbWeb.mdb |
HTML extensions | Yes | Yes |
Extension files | *.HTX | (DBX files) *.HTM |
ISAPI extension | Yes | Yes |
Database connectivity | ODBC | ODBC |
Requires knowledge of HTML | Yes | No (but recommended) |
Requires knowledge of SQL | Yes | No (but recommended) |
Supported by Microsoft | Yes | No |
Source | Included with IIS 2.0 | http://www.microsoft.com |
Benefits of Using dbWeb
The benefits of using dbWeb are many. The most compelling reason for most, however, is the ease with which dynamic content can be published using this tool. Because the process is nearly entirely facilitated by a GUI (the dbWeb Administrator), most users are able to build dynamic content with a minimal amount of effort. Additionally, fairly complex WWW sites can be assembled with little or no knowledge of SQL or HTML. Other benefits include the following:
Benefits of Using the Internet Database Connector
Although dbWeb provides a quick and easy way to publish dynamic content, it has limitations. Because the Internet Database Connector is implemented as a mechanism that simply issues SQL statements and allows for the custom formatting of the resultset, there are few limitations associated with IDC. Other benefits include the following:
Microsoft dbWeb is a utility that enables developers to quickly and easily create dynamic content for their Internet or intranet sites. Through the GUI application called dbWeb Administrator, developers are able to specify the columns that make up Query By Example (QBE) forms, result forms, maintenance forms, and links between them.
To install dbWeb, you must first obtain the dbWeb Setup files. Version 1.1a is available from the CD-ROM included with this book. To check for the availability of a newer version, consult the Microsoft dbWeb home page as described in a following section "Where to Find dbWeb."
Requirements for Installing dbWeb
Microsoft dbWeb can be installed on nearly any PC capable of running the I386 version of Windows NT, including PCs with a 486, Pentium, Pentium Pro (or higher), or a compatible processor. At this time, Alpha, MIPS, PowerPC, and foreign versions of Windows NT are not supported. Specific requirements include the following:
NOTE: dbWeb may stop running unexpectedly if ODBC has not been upgraded to 2.50 or greater or if Service Pack No. 4 or greater has not been installed when running with Windows NT. Both of these updates are available on the Microsoft Internet site.
TIP: It may be necessary to reboot your machine after upgrading ODBC to ensure that the latest DLL images are loaded into memory.Service packs for Windows NT Server can be obtained from the Microsoft Windows NT Server Technical Support page on Microsoft's WWW site. The URL is http://www.microsoft.com/ntserversupport.
Service packs for Windows NT Workstation can be obtained from the Microsoft Windows NT Workstation Technical Support page, which is also on Microsoft's WWW site. The URL is http://www.microsoft.com/ntwkssupport.
Windows NT Workstation and Windows NT Server use the same service pack. In addition to the WWW pages mentioned, the service pack can be downloaded from Microsoft's FTP server at ftp://ftp.microsoft.com/bussys/winnt/winnt-public/fixes/usa/NT351/. At the time of this writing, the current service pack is No. 5, which is located in the ussp5/i386/ directory.
Before installing dbWeb, Microsoft Internet Information Server or Microsoft Peer Web Services must also be installed. The dbWeb Setup application will stop the IIS service if it is running, but will restart it when the installation is complete.
Tips for Configuring a Development WorkstationDevelopment using dbWeb or Internet Database Connector can be done on a machine configured with Windows NT Workstation 4.0. It is not necessary to have Windows NT Server 3.51 or 4.0, nor is it necessary to have Internet Information Server installed. The Peer Web services that ships with Windows NT Workstation 4.0 is compatible with both dbWeb and Internet Database Connector.
If SQL Server is the target database, it is also possible to use Microsoft SQL Server, Developer Edition. Although SQL Server requires Windows NT Server, SQL Server, Developer Edition will operate on Windows NT Workstation.
Finally, although it is not necessary to have the development machine connected to a LAN, it is necessary to have networking services installed and running. If a network interface card (NIC) is not installed in the development machine, install the MS Loopback Adapter instead. This enables Microsoft networking to operate as if the machine is connected to a LAN.
Where to Find dbWeb
The dbWeb files can be downloaded from the Microsoft Web site. They are packaged in two forms: a 7.45M self-extracting .EXE file named dbweb11a.exe or six self-extracting files named disk1.exe through disk6.exe. The latter option provides for downloading to floppies. Other sources of useful information include the following:
NOTE: As of the time of this writing, the current version of dbWeb is 1.1a. Check the dbWeb home page located at http://www.microsoft.com/intdev/dbweb/ for a description of what is included in this new version, or the availability of newer versions.
The files required to install dbWeb can also be found on the CD included with this book, as well as on the Windows NT Resource Kit.
Installing dbWeb
Installation of dbWeb is facilitated by a Setup Wizard. The first and second screens simply presents a welcome message as well as the usual copyright warnings and license agreement. The third screen, shown in Figure 24.1, asks for the destination directory to be provided. Most users will accept the default.
The dbWeb Setup Wizard asks for the destination directory to be specified prior to installation.
The Setup Wizard will next allow the installer to specify which components are installed as shown in Figure 24.2. While most users will want to install all components, it may not always be necessary.
The dbWeb Setup Wizard allows some or all of the provided components to be installed as needed.
Finally, the dbWeb Setup Wizard will next attempt to determine the default HTML and scripts directory for the IIS installation as shown in Figure 24.3. Most users will accept the defaults provided; however, different directories may be provided as indicated.
The dbWeb Setup Wizard allows the default HTML and scripts directories to be overridden; however, for most users this is not recommended.
If IIS service is running, the dbWeb Setup Wizard will ask to stop the service before continuing. Once the service is stopped, setup will copy the necessary files as required. The dbWeb service is then registered and the default ODBC Data Source Name (DSN) is created. Finally, setup asks to restart the machine to ensure all of the proper images are loaded into memory.
Once the installation routine has been successfully completed and the machine has been restarted, ensure that ODBC version 2.50 or greater is installed. The dbWeb icon should then be available on the Start menu for use.
Configuring dbWeb
Using the dbWeb Administrator Preferences Editor, many of the default values used
when creating new schemas can be changed. Prior to creating a schema, these items
should be configured for your installation. To invoke the Administrator Preferences
Editor, start the dbWeb Administrator and choose Edit, Pr
eferences.
The Administrator Preferences Editor is implemented using a tabbed dialog box, which includes two tabs. The Schema Defaults tab provides for the configuration of the default values used in the creation of a new dbWeb schema. The General tab, shown in Figure 24.4, includes the following items:
The General tab of the dbWeb Administrator Preferences Editor is used to change the default values used in the creation of new dbWeb Schemas.
The Schema Defaults tab is where the default values for the Schema Editor are maintained (see Figure 24.5). Setting these defaults affects the default values that are provided upon creation of a new schema. The available items include the following:
The Schema Defaults tab of the dbWeb Administrator Preferences Editor is where defaults for the Schema Editor are maintained.
Additional preference settings can be specified using the Server Preferences Editor. To invoke this editor, click the Server button on the Administrator Preferences Editor. As with many of dbWeb's editors, the Server Preferences Editor is implemented using a tabbed dialog box. The first of these tabs is the Paths tab, which includes the following settings (see Figure 24.6):
The Paths tab of the dbWeb Server Preferences Editor is used to specify default paths for major dbWeb components.
The second tab of the Server Preferences Editor is named Internal and is shown in Figure 24.7. The options of this tab include the following:
The Internal tab of the dbWeb Server Preferences Editor is used to set options pertaining to the operational maintenance of the dbWeb solution.
The final tab of the Server Preferences Editor is the Special tab, which is shown in Figure 24.8. The options of this tab include the following:
The Special tab of the dbWeb Server Preferences Editor is used to set options which determine the type of HTML generated by dbWeb.
Under normal circumstances, the options in the dbWeb Server Preferences Editor should remain set to their default values. These options are provided for advanced developers and should only be altered during development or to fine-tune a busy dbWeb solution.
The dbWeb tool has several componentsñboth physical and conceptualñthat all work together to provide a rather comprehensive solution. The physical components, such as software and database files, are as follows:
TIP: It may be desirable to upsize the dbWeb repository database from Microsoft Access to Microsoft SQL Server. Doing so can result in better performance. For further information on upsizing your dbWeb repository database, see the dbWeb FAQ at http://www.microsoft.com/intdev/dbweb/dbwfaq.htm. The procedure is described in the "Technical Tips and Tricks" section.
CAUTION: Do not attempt to convert the dbWeb Repository Database from Microsoft Access 2.0 format to a newer format. Doing so renders the database unreadable by the dbWeb Administrator.
The conceptual components are the soft components of a dbWeb solution. These components include the following:
It is important to note that the use of ODBC enables databases of virtually any type to be accessed by either the IDC or dbWeb. The only requirement is an ODBC driver for the version of ODBC being used.
Related Microsoft Knowledge Base ArticlesMicrosoft Knowledge Base article Q155255 documents a problem that causes IIS to stop responding. This article refers to article Q151186, which discusses an update to JET.
The problem described in these articles may also cause Microsoft Access queries to run slowly on Windows NT 4.0. This may be relevant if an Access database is being used as the data source for your Web page. Article Q143163 describes this problem and also recommends the update.
This update is recommended especially when using IDC and dbWeb together. The update can be downloaded from ftp.microsoft.com and is named MSJTWNG.EXE.
ODBC 2.50 is distributed with dbWeb 1.1 and should be installed on the machine that is to run dbWeb. The dbWeb's Setup application installs an ODBC setup image in the dbWeb\Odbc32 directory. Run setup.exe from that directory to install ODBC 2.50.
ODBC 2.50 provides support for System Data Source Names (DSN), which are required for using ODBC with Microsoft Internet Information Server (IIS). System DSNs enable Windows NT services to access ODBC without the need of a user account. Both IIS and dbWeb are implemented as Windows NT services and therefore require this capability.
NOTE: Be sure to create all ODBC data sources as System DSNs. Both IDC and dbWeb can use only System DSNs.
Use the ODBC Administrator to define DSNs for use with dbWeb. The utility can be invoked in many ways, as follows:
The dbWeb Administrator utility provides the vast majority of the functionality required to administer a dbWeb solution. It is sometimes necessary, however, to use other tools and utilities to provide setup for, or to extend the basic capabilities of, dbWeb. The following sections describe some of the procedures you will use to set up and maintain your dbWeb solution.
Registering an ODBC Data Source
To register a DSN for the first time, ensure that the Data Sources and Schemas
node is selected in the main tree view of the dbWeb Administrator. This is the root
node and therefore should be the topmost node. Notice that as this node is selected,
the first of the three buttons on the toolbar changes to read New
Datasource. Press this button to invoke the Data Source Registration Editor, as shown
in Figure 24.9.
The dbWeb Data Source Registration Editor is used to register data sources for use in the dbWeb Administrator.
To modify an existing DSN registration, select the appropriate node. The text
in the second button in the toolbar should change to Modify Datasource
if it is not already labeled as such. Press this button to invoke the Data Source
Registration Editor. Removal of a DSN registration is as simple as selecting it from
the main tree view and pressing the Delete Datasource button.
The Data Source Registration Editor is implemented using a tabbed, dialog box control. The following tabs are available while creating or editing a DSN registration:
CAUTION: Care should be taken when deleting a DSN registration because all related schemas are automatically deleted. Although a confirmation dialog box is presented upon the request to delete a DSN registration, there is no indication that the related schemas will also be deleted.
TIP: The data source list window is small by default, but you can use your mouse to increase its size to see the entire name for all of your DSNs.
TIP: When creating the SQL Server accounts used for dbWeb access, specify the default database. Doing so ensures that if a database name is not specified in either the ODBC DSN or in the dbWeb Data Source Registration, the default database is automatically connected to.
Creating a Schema
Once the data source is registered, one or more schemas can be defined for that
data source. To add a schema, a data source node or a peer schema node must be selected
from the tree control in the dbWeb Administrator. Upon doing so, the first of the
three buttons in the toolbar changes to read New Schema. Pressing
this button causes a dialog box to appear enabling a schema to be created using either
the Schema Wizard or the Schema Editor.
The Schema Wizard
The Schema Wizard is useful for getting a quick start at creating the most simple queries. Because multiple tables cannot be joined by the Schema Wizard, most schemas require the use of the Schema Editor.
Not unlike many of the wizards used in other popular products, the Schema Wizard consists of a series of dialog boxes that prompt for pertinent information in an intuitive manner. The user is guided through the process of creating a schema, step by step. Until all required information is provided on a given page, the user is prevented from moving to the next step.
Navigation is also similar to many other wizards. Along the bottom are buttons
that enable the user to move forward (the Next button) and backward
(the Previous button). Also provided is a Cancel
button, enabling the user to leave the wizard without saving changes, and a Finish
button, which becomes available when all of the required information has been provided
on all the pages of the wizard.
The dbWeb Schema Wizard consists of five dialog boxes asking for the minimum information required to create a schema. These are as follows:
A dbWeb Query By Example Form allows the user to provide criteria upon which a query is based.
A dbWeb Tabular Form displays a multiple row result set in table form.
The Schema Editor
The Schema Editor provides a facility for the creation and management of dbWeb schemas. The Schema Editor is implemented using a tabbed dialog box and allows for the maintenance of all aspects of a dbWeb schema. A brief description of each tab follows.
To invoke the Schema Editor to create a new schema, first select either a data
source node or a peer schema node from within the target data source. Doing so causes
the text on the first button to change to New Schema. Press this
button to invoke a blank Schema Editor.
Editing an existing schema is similar. First select the schema to be edited, then
press the Modify schema button. Note that the text for this button
changes as a schema is selected in the tree control.
TIP: To maximize performance, dbWeb caches much of the schema information. It is therefore sometimes necessary to stop and restart the dbWeb service in order for changes to take effect.
There are two types of schemas: those based on tables or views and those based on procedures. See the discussion on the Database Object Type grouping of the Schema tab for details on selecting between a table/view-based schema and a procedure-based schema. The following describes the tabs that are available when creating a schema based on tables or views:
- The Schema Name is that which appears in the tree control of the main dbWeb Administrator window. This name is also used to call the schema from within HTML documents.
- The Browser Title Bar field contains the title that is displayed in the client's browser to be specified. These titles should be very brief but descriptive because it is the text saved in the Favorites menu of Internet Explorer.
- The Mail Comments to field enables an HTML mail link to be specified, which then can be used by the viewer to send mail to a particular user. This field must contain valid syntax for an HTML link, including the <A HREF="..."> and the </A> tags.
- The Page help URL field allows for a path to an HTML document or any other valid URL to be specified as a help page. The link is presented as a 3-D Help button on the displayed page. This value is provided by default as the value specified in the dbWeb Administrator Preferences.
- The Default Max Rows field allows for a maximum number of rows to be set. This becomes a necessary feature when large databases are used. Such databases could potentially return thousands of rows for a given query, resulting in unwieldy or unusable resultsets to be displayed.
- The Allow Actions On Data grouping enables actions to be carried out on the data by the viewing user. The actions include Insert, Update, and Delete. If any one of these three options is selected, the Ins/Upd/Del tab becomes enabled. Note that if the Database Object Type is set to be a procedure, this grouping along with the SQL grouping are disabled as these options are not valid with that object type.
- The SQL grouping has a single option, which is labeled as Select Distinct Records Only. When this option is set, duplicate rows of data are suppressed. Depending on the structure of the underlying database, this option may or may not have an effect on the resultset generated by the schema.
- The Database Object Type grouping allows for the selection of either Table(s) or View(s) or Procedures. Changing this option changes the mode of the Schema Editor entirely; some of the tabs change and some of the options become unavailable.
CAUTION: If the Database Object Type is changed after any information is entered, this information is discarded, and the Schema Editor is reinitialized as if a brand new schema were being created.
TIP: If an Access database is being used, it is not possible to create outer-left and outer-right joins using the standard *= and =* operators. The suggested workaround is to create a QueryDef in the Access database and use its resultset in your dbWeb schema as you would any other table.
TIP: For a list of all available dbWeb methods, click theHelp button on any of the editors, which invokes dbWeb Help. Once in Help, click theContents button and select the Developer's Reference link. A link to the dbWeb Methods page is available there.
TIP: The Properties Editor and the Computed Column Expression Builder can be invoked from a context-sensitive, tear-off menu, which is presented in response to a right-click of the mouse.
The Properties Editor is where the attributes of a schema are modified.
The Computed Column Expression Builder dialog box provides the ability to create computed columns.
NOTE: A single-record resultset is one that contains only one row from the underlying database, whereas a multi-record resultset contains two or more.
Linking Your Schemas Together
It is often desirable to call one schema from another in response to the viewer's selection of an automatic link. In most cases, this will be a mechanism that represents a parent/child relationship in the database itself. An example might be a schema that lists active clients and a link to another schema that lists the active projects for the selected client. It may also be a link to a different view of the same data..These links are created with the Automatic Link Editor, which is shown in Figure 24.14.
The Automatic Link Editor is used to define the links between different views of the same schema or different schemas altogether.
To invoke the Automatic Link Editor, the column that is to be the source of the
link must first be selected. This can be done from either the Tabular tab or the
Freeform tab. Doing so causes the Properties button to become available;
pressing this button causes the Properties Editor to be displayed. As the Automatic
Link URL property is selected, a small button labeled with ellipsis points (...)
becomes available that, when pushed, causes the Automatic Link Editor to be displayed.
Several types of links are supported by dbWeb, as follows:
TIP: If your criteria require a multi-part primary key to be defined, consider using a schema link to link to a different schema. The schema link allows for multiple criteria to be defined on different columns in both the source and target schemas.
DBX Files and Tags
To enhance both the input and output of dbWeb, consider using .DBX files. These files allow for the output of a dbWeb schema to be formatted in nearly any way possible with HTML. More importantly, however, is the capability of dbWeb to format your results using report banding features common to most report building tools. Report banding enables a section of your HTML document to be repeated for each row in a resultset.
NOTE: The creation and maintenance of .DBX files require an understanding of HTML.
.DBX files are simply HTML files with tags recognized by dbWeb embedded in them. For example, the \TBON and \TBOFF tags identify the start and end of a repeating section, respectively. Other tags identify columns from the resultset. Because .DBX files can be used for QBE forms as well as Insert/Update/Delete forms, extensions to HTML INPUT tags can also be used.
TIP: To use a different .DBX file for single-record or multi-record resultsets, define a new schema. This is just one of a handful of reasons why it is often necessary to have different input schemas and resultset schemas.
Create .DBX files for your schemas using a simple text editor, such as Notepad, or with the DBX Editor supplied with dbWeb Administrator. The DBX Editor is available by pressing the Editor button on the DBX tab of the Schema Editor.
TIP: Use your favorite HTML editor, such as Microsoft FrontPage or Internet Assistant for Word, to generate the HTML for your basic document. Once the majority of the HTML has been generated, use Notepad or the DBX Editor to add the .DBX tags.
All DBX tags must adhere to a format that is recognized by dbWeb. That format is as follows:
\TOBJ\T{Table Name}\TCOL\T{Column Name}\T
Substitute the actual names of the table and column as indicated when editing your .DBX files. HTML formatting tags can be placed before and after the tags.
TIP: For an overview of the available HTML tags, consult the Microsoft Site Builder Workshop site. The URL is http://www.microsoft.com/workshop/author/newhtml/default.htm.
The banding tags also must adhere to a specific format. A repeating section must start with a BON tag and end with a BOFF tag. The format for the BON tag is:
\TBON\TMATCH\T{Table Name}\T{Column Name}\T
Again, substitute the actual names of the table and column as indicated when editing your .DBX files. The tag for the BOFF tag is as follows:
\TBOFF\t
Calling dbWeb Schemas from HTML Documents
Once you have created your schemas using the dbWeb Administrator, you need to embed references to them in your HTML documents. This is typically done by referring to the dbWeb Client Stub followed by the schema name. This is then followed by the query operator, a question mark, and the desired dbWeb method.
The following example is a portion of the dbWeb test page, which is installed with dbWeb to test the installation. The name of the file is DBWTEST.HTM. By default, it is installed in the dbWeb folder located in the wwwroot directory:
... <I><A NAME="Microsoft"><H4>Microsoft Internet Information Server Test</H4></A></I> <UL> <B>Pubs Examples</B><BR> <LI><A HREF="/scripts/dbWeb/dbWebc.dll/Titles?getqbe">Titles</A> <LI><A HREF="/scripts/dbWeb/dbWebc.dll/Authors?getqbe">Authors</A> <LI><A HREF="/scripts/dbWeb/dbWebc.dll/Stores?getqbe">Stores</A> <LI><A HREF="/scripts/dbWeb/dbWebc.dll/Publishers?getqbe">Publishers</A> <LI><A HREF="/scripts/dbWeb/dbWebc.dll/Author_Titles?getqbe">Author_Titles</A> <LI><A HREF="/scripts/dbWeb/dbWebc.dll/Store_Sales?getqbe">Store_Sales</A> </UL> ...
As shown by the previous code, the Titles schema is called through a reference to the dbWeb Client stub. The stub is located in the /scripts/dbWeb directory, the path of which is relative to the wwwroot. The getqbe method is called when the user selects the link shown as Titles on the user's browser screen.
Viewing the Visitor and Error Logs
As indicated by the IP Log option in the Server Preferences Editor, dbWeb is able to keep a log of the activities it is requested to perform. The visitor log is written as text files to paths specified using the preferences editor. By default, the log is located at C:\Dbweb\Service\DbwIP.log. The columns in the log are thread ID, date, time, IP address, dbWeb method, and any method parameters.
dbWeb reports its errors using the Windows NT Event Log. To view the errors, select the Application log in the Windows NT Event Viewer, and look for entries that contain dbWeb in the source column. Note that all requests, even those that result in an error, are also logged to the visitor log as well.
The Internet Database Connector (IDC) is an ISAPI extension installed as a standard component of the Microsoft Internet Information Server. Through this extension, access to ODBC data sources is provided.
IDC uses two types of files to define the way information is requested and the results of the request are formatted. These files are Internet Database Connector files (*.IDC) and HTML Extension files (*.HTX). The connector files provide a query and a few connection parameters. The resultset is then formatted using the extension files, based upon tags placed within them.
Unlike dbWeb, IDC is not an application capable of creating and maintaining dynamic content templates. It is merely the filter component which is capable of parsing HTML documents with embedded IDC tags and responding to them accordingly. By providing queries in connector files and sophisticated HTML in the format files, much can be done to produce dazzling dynamic content.
NOTE: Development using the IDC requires a thorough knowledge of both SQL and HTML. A basic understanding of ODBC is also recommended.
The IDC is installed when IIS is installed, so unlike dbWeb, there is nothing more to install. The only additional requirement is that ODBC 2.50 must be installed on the machine.
CAUTION: The ODBC driver for Microsoft Access 2.0 is not compatible with Internet Information Server or the Internet Database Connector. It is therefore necessary to use the ODBC 2.50 driver.
IDC is implemented as a .DLL named Httpodbc.dll, which is installed in the IIS directory by default. This ISAPI extension is mapped in the registry to handle files with the .IDC extension.
Based upon field values and option settings in these files, queries are issued to the ODBC data source. The resultset is then formatted based upon special tags in the HTML extension file specified in the .IDC file. The resulting HTML document is then routed back to the client browser by IIS.
Internet Database Connector files have the extension .idc and contain the SQL statement of a query. Also included are a handful of required option fields that specify the ODBC DSN and the output format file. The IDC files can also include one or more of the optional fields used to further customize the way the query is issued. The following fields are required in every IDC file:
The query statement specified in the IDC file can be any valid SQL statement. This includes INSERT, DELETE, and UPDATE queries. While not a common query construct, SQL Data Definition Language (DDL) can also be used in the IDC files to create tables, indices, constraints, stored procedures, triggers, or even drop the same objects. The SQL that can be used is dependent upon the ODBC driver and the underlying database server.
The following snippet of code shows the contents of viewbook.idc, an IDC sample file included with IIS. Note that the Datasource is an ODBC DSN named Web SQL. Two optional fields, Username and Expires, are included in this example. They indicate that sa is the username to be used to gain access to the database and that the resultset is held in cache for two seconds before being considered expired. Expired resultsets are requeried when their results are next requested:
Datasource: Web SQL Username: sa Expires: 2 Template: viewbook.htx SQLStatement: +SELECT FirstName, LastName +FROM Guests
A SQL statement can be of nearly any length, depending on its complexity. Regardless, it is advisable to break up your SQL statement into multiple lines for readability. To do so, ensure that a plus sign (+) is used at the beginning of each new line.
There are many other fields that can be included in the IDC files. For a comprehensive discussion of these fields, consult the online documentation included with IIS. The IDC is discussed in Chapter 8, "Administering Windows NT Server."
In many instances, it is desirable to let the user specify criteria for a search. This can be done using standard HTML constructs, as shown in the following code snippet taken from Chapter 8 of the IIS documentation, "Publishing Information and Applications." Note that all of this code is standard HTML; nothing specific to IDC has been used with the exception of the action being defined to call the .IDC file:
<FORM METHOD="POST" ACTION="/scripts/samples/sample2.idc"><P> Enter YTD sales amount: <INPUT NAME="sales" VALUE="5000" ><P> <INPUT TYPE="SUBMIT" VALUE="Run Query"> </FORM>
In this example, the user is asked to provide a value for YTD sales. The default is 5,000, which can be overridden by the user. When the user clicks the Run Query button, the form's SUBMIT method is called, which is defined to call SAMPLE2.IDC. The code from SAMPLE2.IDC, which is again borrowed from the IIS documentation, is as follows:
Datasource: Web SQL Username: sa Template: sample.htx SQLStatement: +SELECT au_lname, ytd_sales + from pubs.dbo.titleview + where ytd_sales > %sales%
Note that the SQL statement includes %sales% in the where clause. This is the value supplied by the user. For example, if the user had supplied 2,000 instead of the default 5,000, %sales% would be replaced by 2,000 before being submitted to the ODBC driver for processing. The resultset would then include only those rows where the value in the ytd_sales column is greater than 2,000.
Just as the user is asked to provide a value using a standard text edit control, standard HTML Select Multiple list boxes can also be used to specify input. Just as %sales% variable was referenced in the .idc file in the previous example, so can a variable defined as a Select Multiple list box. IDC conveniently replaces the variable name with the actual values.
CAUTION: Pay close attention to the condition described in the "Using Select Multiple List Boxes in HTML Forms" section of Chapter 8 in the IIS online documentation. This discussion describes the significance of the placement of single quote marks around the variable name defined by the HTML SELECT MULTIPLE tag.
HTML Extension files are very similar to dbWeb's .DBX files in purpose. These files contain special formatting tags embedded in a standard HTML document. These tags determine how the resultset of a query is formatted. These tags are enclosed with special delimiters, <%tag%> or <!--%tag-->. The tags available for use in .HTX files include the following:
In addition to these tags, any column can be included by enclosing the name of the column in the standard HTX delimiters. For example, to include the column CustomerName in the HTML document, use <%CustomerName%> in your .HTX file.
Also available in the .HTX files are all of the HTTP variables defined and populated by IIS. A comprehensive list of these variables and their contents are described in Chapter 8 of the IIS online documentation.
Microsoft FrontPage Integration
The .IDC files required by IDC can be easily created using the FrontPage Editor's
Database Connector Wizard as shown in Figure 24.15. This wizard quickly collects
the information necessary to generate an .IDC file automatically. FrontPage will
also use the wizard for subsequent edits of the .IDC file. To invoke the Database
Connector Wizard, select File, New, and then select
Database Connector Wizard from the list of available templates.
The FrontPage Editor's Database Connector wizard collects the information necessary to generate an IDC file automatically.
Result templates (.HTX files) can be just as easily created with FrontPage's Database
Results template. Selecting this template yeilds a blank editor window in which any
HTML document can be created. The primary difference however is the Database
submenu located on the Edit menu. This menu provides for the insertion
of IDC tags into the HTML document. Refer to the FrontPage documentation for specifics
on these items.
This chapter is an overview of two tools used to create and maintain dynamic content with Microsoft Internet Information Server. By comparing and discussing many of the major features of each tool, it should be possible to determine which tool is best for the needs of most developers.
In addition to learning about the topics discussed here, it will likely be necessary to consult other chapters in this book to ensure that the solution provided with these tools is complete, secure, and error-free. For additional information on these topics, consult the following chapters:
© Copyright, Macmillan Computer Publishing. All rights reserved.