Professional Documents
Culture Documents
Li Yi
South Bank University
Contents
1. Introduction ...................................................................................................................................... 2
1.1 Host-based databases ............................................................................................................... 2
1.2 Client/server databases ............................................................................................................ 2
1.3 Web databases........................................................................................................................... 3
2. Active Server Pages ........................................................................................................................ 5
2.1 ASP Components ...................................................................................................................... 6
2.2 ADO and Database................................................................................................................... 7
2.3 The steps of executing a query ............................................................................................. 11
3 ASP Attributes ................................................................................................................................ 12
References:.......................................................................................................................................... 13
1. Introduction
The development of databases always comes with the newer and better
hardware and the demand for applications that match the new hardware. In the
past 20 years, we have seen the development of databases not only in DBMS,
but also in the evolution of database connectivity, which is from centralised
computing to Client/Server computing. These client/server structure databases
have a great impact to the use of databases.
databases need to be extended their services to the biggest wide range group,
web group.
The typical web databases are three-tier or N-tier. The users run standard
browsers on the client side and the requests are transferred over the Internet to
HTTP servers. The HTTP servers then interact with database servers and
change the result into HTML files to send back to the browsers. Because
HTTP is a stateless connection protocol, web databases need find a way to
"remember" each user's operations. They also should have capability of
handling with enormous users concurrently. If the web databases support Java,
or ODBC/JDBC, they are platform independent because they can connect with
different web servers or the Internet directly. It does not need to care about
server platform, client platform and network protocol.
Web databases can be two-tie, three-tie or N-tie. The two-tie web databases
are the simplest to develop and may gain some good performance from this
simple structure. However, they are lack of flexibility to deal with other web
things and normally they are vendor dependence. The three-tie or N-tie web
databases are powerful and flexible. But the middle tie may add the overhead
because the databases are not connected with the Internet directly.
ASP is supplied with ActiveX Data Objects (ADO) that provides a high
performance interface to databases that are Open Database Connectivity
(ODBC) or OLE DB compliant. Fig. 1 shows the general structure of how
ASP to connect the databases.
Server: Windows NT
Internet Information Server
CGI
Client
Scripts
Internet
WWW
ASP
ADO
SQL
Server
Or
Oracle
ODBC
Browser
ActiveX
MTS
HTML
files
*ADO is a high-level interface, which is a wrapper around OLE DB. OLE DB is a COMbased, low-level programming interface that provides access to data from all parts of an
organisation (relational, access, file).
* If there is a native OLE DB provider for the database, it does not have to go through ODBC
- the extra layer of processing.
There are six built-in objects provided by the Active Server Pages core engine.
These objects are Application, Session, Response, Request and ObjectContext.
They only relate to each other logically, not in a hierarchy object models. The
diagram below shows how these objects fit together.
Server
Object
Request
Client
Response
Server
Application
ObjectContext
Session
pages in the application; instead, these variables persist for the entire time the
user is accessing pages in the application.
ObjectContext objects
The ObjectContext object is used by Microsoft Transaction Server (MTS)
initiated to commit or abort transactions.
These objects cover normal web server functions. But when a client request
needs to query a database, ADO will be needed.
2.2 ADO and Database
To develop a dynamic web site, web pages is needed to link with a database of
some kind. (It is not that kind of static pages translated from databases.) The
traditional way to do that is through Common Gateway Interface (CGI) or
Internet Server Application Programming Interface (ISAPI) directly. An easier
way is provided by ASP, which is supplied with a component called the
Database Access Component. The component is a whole hierarchy of objectscollectively known as the ActiveX Data Objects (ADO), which is the 'missing
link' between web pages and almost any kind of stored data.
Connection
Command
Parameters
Parameter
Recordset
Fields
Errors
Error
The object model is like a hierarchy structure, but not absolutely. One
command can be executed by different ways with different objects. The
following is a briefly introduction all of the objects and collections shown in
the figure.
The Recordset object is the most intricate of the ADO objects. It supports
features such as data paging, disconnected recordsets, filtering, sorting, and
storing multiple data sets in a single Recordset object.
Connection
Before we can access any part of a database, we need to establish a connection
to it. A predefined link between the consumer and the data provider can be
built by creating an instance of the Connection object, and placing information
in its properties.
The default ConnectionTimeOut is 15 seconds.
Filtering
The Filter property of the Recordset object can reduce the number of records
that users can see in a recordset based upon their filter criteria. All the
information is still there in the recordset - it is just hidden from view until the
users clear the filter. By applying the filter, the users only get a subset of all
the rows.
Paging
This is a good way to look at data one 'page' at a time. It would not take any
custom programming to implement this.
Indexing
Indexing will reduce processing time when performing searching for a record
and sorting a recordset. But the index itself resides in the client-side cursor
that ADO provides. That means it is not indexing the database itself, it is
indexing the Recordset object.
Execute SQL
It is important to define a right execute method for executing SQL code
against the data provider. For example, if the adExecuteNoRecords is not
defined in the execution of a SQL statement which does not need to return any
record, ADO will generate a recordset of no records, which takes up extra
memory and time and is essentially a waste of resources.
Stored procedures
To use a stored procedure within a database can get much better performance
than to running a dynamic query because the stored procedure is already
10
Transactions
ADO has a number of methods and properties to support transactions.
Disconnected Recordset
ADO gives us disconnected and remote-able recordsets, which in turn allows
for better functionality in the stateless environment of the WWW.
11
If yes, it will use that to connect to the database server. If no, it will create
a new connection.
6. After setting up the connection, the Command object will tell the database
server what should be done. This command goes through ODBC or OLE
DB and is changed to a language that the database can understand.
7. The Recordset object will get the result and then manipulate it to produce
the web page.
8. When there is no need to interact with the database server, the connection
to the database will be closed and the connection will be thrown in the
connection pool.
9. The resulting web page is sent back to the user, and the data fetched from
the database server will be left in the cache.
3 ASP Attributes
Performance
ASP is a script language, which means the web server needs to read each line
of the ASP file and then run it. Microsoft Transaction Server (MTS) can be
used to improve the performance of ASP. MTS is viewed as an object broker
and uses COM to map client applications to services resident in software
components (objects). It is designed to reduce the time and complexity in the
development of N-tier applications by supplying much of the infrastructure to
provide a robust, scalable, high performance and distributed architecture.
Portability
ASP is originally designed to run on Windows environment. However,
Chili!Soft Inc. (http://www.chilisoft.net/) have implemented an ASP scripting
engine for many non-Microsoft Web Servers and they claim that this is
functionally equivalent to the Microsoft implementation. This means that ASP
does not force vendor lock-in and your Web applications can now be freely
ported to other platforms (like Unix) without code change.
Powerful
12
ASP can not only run some scripts and connect different databases through
ODBC, but also do other things through ActiveX server components.
Scalability
Future versions of MTS will work with the Cluster Server technologies to
provide dynamic load balancing, scalability and high availability.
Learning curve
It is easy to learn because it is just a script language and it uses Visual Basic
syntax.
References:
Scott M.
Lewandowski
(1998)
"Frameworks
for
Component-Based
13