DS 420ssg b | ![]() ![]() |
Dr.Elliott |
We wanted to research how hard it is to implement a web based data access system. We have already looked at the following technologies : CGI, Dcom, Java, O'Reilly Web Server. We chose to investigate Microsoft's latest Web development technology. Microsoft has claimed that even a "novice" should be able to implement a relatively powerful Web site with few problems. The major components neccesary for such a system include :
Internet Explorer
Operating Systems/Microsoft Transaction Server
¡@
Internet Information Server
Internet Information Server (IIS) 4.0 is a high-performance Web application server for Windows NT Server. IIS brings many advanced capabilities to Web professionals, both as a Web server for corporate intranets and public Internet sites and as a platform for the next generation of line-of-business applications.
IIS incorporates World Wide Web (WWW), File Transfer Protocol (FTP), Index Server, and Secure Sockets Layer (SSL) services. IIS provides a comprehensive set of tools for managing the Web server and its components.
IIS makes it easy to build scalable and reliable applications for the Web. With IIS, you can easily integrate the benefits of transactions into Web applications. IIS brings together the advantages of Windows NT Server, with a range of services for client/server development, and the standards of the Internet to create a true Web platform for distributed applications. The following illustration shows the relationship between IIS and the supporting Web services that can be used.
IIS and many of the technologies in this illustration are shipped as a part of the Windows NT Option Pack, available from the Microsoft Web site.
¡@
IIS is the only World Wide Web server that:
IIS version 3.0 introduces Active Server Pages, a technology that makes it easy to integrate server business solutions with HTML Web content. ActiveX server pages enable Web content creators to:
HTML content deployed as Active Server Pages can invoke business components running in Transaction Server. This extends Transaction Server scalability and component flexibility to Internet applications, combining "RAD" and "RAS" for the Internet.
¡@
Integration with Microsoft Transaction Server
Implementing a Three-Tier Application with IIS
IIS fits into the three-tier application model primarily as an implementation technology for the presentation layer. The ASP logic runs on the server and provides HTML output to the browser.
For example, in a common scenario the user loads a Web URL in their browser. The Web browser invokes an ASP file on the Web server; the ASP contains script that references components. These components contain the business logic.
The components are part of the business tier, and may run on a separate server. The components access and manipulate information from databases. The components pass results back to the ASP file, which in turn formats the results as HTML output, which is then returned to the requesting browser.
MTS plays the role of coordinator in the middle layer, working with IIS to process client requests across components and databases that can be anywhere on the network. MTS allows developers the flexibility to deploy applications with the best design for their network, clients, and servers. Code can be run on any tier.
IIS Software Development Kit (SDK)
IIS 4.0 includes a Software Development Kit to help developers understand the Web application programming services available. The SDK provides developers with a number of examples in the following areas:
ASP examples
These are designed to give new users an overview of the capabilities of server-side scripting in general, and ASP in particular, while at the same time providing more advanced examples for experienced developers who want to discover what ASP can do for them.
Component examples
The IIS 4.0 SDK contains several examples that demonstrate key concepts in component construction. There are several samples provided, including source code in Visual Basic, Visual C++, and Java.
Internet Server Application Programming Interface (ISAPI) examples
Using ISAPI, developers can add to the functionality of IIS, and create Web-based applications that have as much functionality as any desktop application. The IIS 4.0 SDK provides a number of ISAPI Extensions and Filters to demonstrate how to use the ISAPI interface.
The Microsoft Personal Web Server also support ASP.
Operating Systems/Microsoft Transaction Server
Windows 98 is an evolutionary upgrade, not one that significantly redefines the way you work with your PC. The main reason to switch to Win98 is just that it runs better than Win95 and, you'll be able to upgrade from Win98 to NT 5.0 (if all goes as Microsoft plans). If you're happily running NT 4.0 or you know NT 5.0 is your destiny then don't worry about Windows 98 On the other hand Win98 would be be a useful upgrade for most Windows 95 users. Win98 improves the Windows platform enough that the upgrade is well worth the $89 price.
Win NT is Microsofts flagship operating system. It was developed from the ground up beginning in 1988. Because of this it does not have Windows 98/95 inherent problems of trying to run as psuedo 32 bit operating system on top of 16 bit program launcher. Some of its goals were/are: portability, multiprocessing and scalabilty, distributed computing, POSIX compliance, and Goververment-Certifaible security. It is a TRUE operating system, proccesses are given their own individual address spaces and they cannot access memory outside of them. The bad news is that it still may have to work on its relaibility a bit.
Microsoft Transaction Server (MTS) handles many of the complexities of developing secure, scalable, reliable and efficient client/server and Web applications. It allows you to focus on coding the business logic rather than the infrastructure.
MTS and IIS are integrated on two different levels:
IIS uses MTS as its application engine
IIS takes advantage of the high-performance thread pool engine built into MTS. While this fact is transparent to most web application developers, it is apparent when looking in the IIS Microsoft Management Console.
IIS supports Transacted Active Server Pages
IIS allows application developers to create Active Server Pages that take advantage of transactions. Any data access performed in the ASP, as well as any components it calls, can be transacted. The transactional support is provided by MTS.
Microsoft Transaction Server is tightly integrated with Microsoft Internet Information Server (IIS), enabling businesses to easily project server solutions over the Internet and intranets.
¡@
ActiveX Data Objects (ADO)
History
ADO was first introduced as the data access interface in Microsoft Internet Information Server. ADO is implemented with a small footprint to provide minimal network traffic in key Internet scenarios, and a minimal number of layers between the front-end and data source. ADO is easy to use because it is called using a familiar metaphor: the OLE Automation interface, available from just about any tool and language on the market today. Because of its popularity as an easy-to-use, lightweight interface to all kinds of data, and the growing need for an interface spanning many tools and languages, ADO is being enhanced to combine the best features of, and eventually replace RDO and DAO, the data access interfaces in widest use today. ADO is in many ways similar to RDO and DAO, for example, it uses similar language conventions. ADO provides simpler semantics, which makes it easy to learn for today¡¦s developers.
ADO is designed to be the application-level interface to OLE DB, Microsoft¡¦s newest and most powerful data access paradigm. OLE DB provides high-performance access to any data source. Together ADO and OLE DB form the foundation of the Universal Data Access strategy. OLE DB enables universal access to any data. ADO makes it easy for developers to program. Because ADO is built on top of OLE DB, it benefits from the rich universal data access infrastructure that OLE DB provides.
ActiveX Data Objects (ADO) is an application-level interface that makes it easy to access any OLE DB data provider, including relational and non-relational databases, e-mail and file systems, text and graphics, custom business objects, and existing ODBC data sources. Virtually all of the data available throughout the enterprise is available using the ADO data access technology.
ADO is an easy-to-use, language-independent interface. It is implemented with a small footprint and uses minimal network traffic. Because ADO minimizes the number of layers between the client application and the data source, it provides lightweight, high-performance data access.
The general characteristics of ADO are:
- Programmatic cursor control
- Complex cursor types, including batch and server- and client-side cursors
- Ability to return multiple result sets from a single query
- Synchronous, asynchronous, or event-driven query execution
- Reusable, property-changeable objects
- Advanced recordset cache management
- Flexibility to work with existing database technologies and all OLE DB providers
- Excellent error-trapping capability
The ADO Object Model
The ADO object model defines a collection of programmable objects that support COM and Automation to leverage the powerful partner technology called OLE DB. The ADO object model, when compared to other data access objects such as RDO or DAO, is flatter (has fewer objects) and easier to use.
The following table describes the seven objects in the ADO object model.
Object Description
Command Maintains information about a command, such as a query string, parameter definitions, and so on. You can execute a command string on a Connection object of a query string as part of opening a Recordset object, without defining a Command object. The Command object is useful where you want to define query parameters or execute a stored procedure that returns output parameters. The Command object supports a number of properties that describe the type and purpose of the query and help ADO optimize the operation.
Connection Maintains connection information such as cursor type, connection string, query time-out, connection time-out, and default database.
Recordset A set of rows returned from a query, including a cursor. You can open a Recordset object (that is, execute a query) without explicitly opening a Connection object. However, if you first create a Connection object, you can open multiple Recordset objects on the same connection.
Error Contains extended error information about error conditions raised by the data provider. Because a single statement can generate two or more errors, the Errors collection can contain more than one Error object at a time.
Field Contains information about a single column of data within a recordset. The Recordset object uses the Fields collection to contain all of its Field objects. This Field information includes data type, precision, and numeric scale.
Parameter A single parameter associated with a command. The Command object uses the Parameters collection to contain all of its Parameter objects. ADO Parameter objects can be created automatically by sending queries to the database. However, you can also build this collection programmatically to improve performance at run time.
Property A provider-defined characteristic of an ADO object. ADO objects have two types of properties: built-in and dynamic. Built-in properties are those properties implemented in ADO and available to any new ADO objects. Dynamic properties are defined by the underlying data provider and appear in the Properties collection for the appropriate ADO object. For example, a property may indicate if a Recordset object supports transactions or updating. This is one of the greatest features of ADO because it lets the ADO service provider present special interfaces.
Using the ADO Objects
A typical ADO-based application uses the following operations to access a data source.
1. Create the Connection object
Specifies the connection string with information such as data source name, user identification, password, connection time-out, default database, and cursor location. A Connection object represents a unique session with a data source.
2. Open the connection
Opens the ADO connection to the data source.
3. Execute an SQL statement
Once the connection is open, you can run a query. You can run this query asynchronously and also choose to process the query's result set asynchronously; ADO signals the cursor driver to populate the result set in the background. This lets your application perform other processes without waiting.
4. Use the result set
The result set is now available to your application. Depending on the cursor type, you can browse and change the row data at either the server or client side.
5. Terminate the connection
Drops the connection to the data source.
Accessing Data with ADO
ADO is the single data interface you need for all client/server and Web-based data access solutions. One of the strengths of ADO is that it can expose and use the unique properties of each data provider. No matter what data source is used, ADO is totally flexible and adaptable to your application's data access requirements.
ADO also includes a client batch cursor library that supports optimistic batch updates. With batch updates, you can create a result set, modify the data as required, and subsequently make all of the changes using the batch update method. This reduces server and network overhead and improves performance.
An important feature of using ADO is the availability of advanced recordset cache management with Remote Data Services (RDS). RDS provides optional data caching on the client workstation. With RDS, you can easily marshal data back and forth between the server and client. For example, your application may use a large client-side result set. This reduces the number of requests for data from the client-side application to the server, improving both the actual performance and the perceived performance of the client-side application. Furthermore, you can open and populate a disconnected Recordset object asynchronously. This improves performance by leaving the client free to execute other tasks while records are still being returned.
Example
ADO can be used in VBScript language inside HTML or Active Server Pages. VBScript code is almost identical to Visual Basic code. For VBScript code to work in an HTML or Active Server Pages, the code must be inserted within a pair of HTML tags or under the Scripting section.
VBScript cannot load ADO constants from the ADO type library; therefore, unless the ADO constants declaration file is included in VBScript code, the literal values of ADO constants must be specified. The Adovbs.inc file contains all the ADO constant definitions and can be included in your script.
To use ADO objects in VBScript, first include the Adovbs.inc file, and then use the CreateObject method to create ADO objects. The Adovbs.inc file can be found in the OLE DB SDK redist directory.
The example shows using ADO in a VB Scripting Web page to list customers¡¦ first and last names in a table:
<%@ LANGUAGE = VBScript %>
<HTML>
<TITLE>Using ADO in a Visual Basic Script Web Page</TITLE>
</HEAD>
<LANGUAGE="VBS">
<!--#include file="adovbs.inc"-->
<CENTER>
<H1><font size=4>Using ADO in a Visual Basic Script Web Page</H1></font><br><br>
<%set myConnection = CreateObject("ADODB.Connection")
myConnection.Open "DSN=pubs;UID=sa"
SQLQuery = "select title_id,title from titles"
set RSTitleList = myConnection.Execute(SQLQuery)%>
<TABLE align=center COLSPAN=8 CELLPADDING=5 BORDER=0 WIDTH=200>
<!-- BEGIN column header row -->
<TR>
<TD VALIGN=TOP BGCOLOR="#800000">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>
Title ID</FONT>
</TD>
<TD ALIGN=CENTER BGCOLOR="#800000">
<FONT STYLE="ARIAL NARROW" COLOR="#ffffff" SIZE=1>
Title</FONT>
</TD>
</TR>
<!-- Get Data -->
<% do while not RStitleList.EOF %>
<TR>
<TD BGcolor ="f7efde" align=center><font style ="arial narrow" size=1>
<%=RStitleList("title_id")%></font>
</TD>
<TD BGcolor ="f7efde" align=center><font style ="arial narrow" size=1>
<%=RSTitleList("title") %> </font>
</TD>
</TR>
<% RSTitleList.MoveNext%>
Over the last six years or so, Microsoft has been driven by customer demand to release an ever-expanding series of data access interfaces. Beginning with the DB-Library interface for Visual Basic ("VBSQL"), and ending with the most recent interface to OLE DB ¡X ADO. Each of these interfaces addressed broadening customer requirements. As Visual Basic applications grew more sophisticated and data-centric, so did the data access interfaces provided:
The evolution of object-based data access interfaces.
With little experience we were able to succesfully set up fully interactive "phone book" using a Web server. Since we were using Windows 95 as our os, we installed Microsoft Personal Web Server. Using the default "address book" in Microsoft Access and by taking advantage of ActiveX Data Objects we could connect and query for a phone number. On a short term basis this would be very appealing for a myriad of small businesses to implement both inranet and internet Web sites. In addition, rapid growth would not preclude a company from using this type of system because Microsoft has created a definite migration path which can easily be taken advantage of. An obvious downside of exclusively using Microsoft¡¦s Web development tools is that one is quickly locked into use of the IE Web Browser and Microsoft¡¦s Web Servers. However, as long one is using this system for an intranet this problem becomes less of a factor.