Web Database Connectivity: Middleware
ASP

Introduction

Microsoft® Active Server Pages (ASP) is a server-side scripting technology that can be used to create dynamic and interactive Web applications. An ASP page is an HTML page that contains server-side scripts that are processed by the Web server before being sent to the user’s browser. You can combine ASP with Extensible Markup Language (XML), Component Object Model (COM), and Hypertext Markup Language (HTML) to create powerful interactive Web sites.

It is possible to extend your ASP scripts using COM components and XML. COM extends your scripting capabilities by providing a compact, reusable, and secure means of gaining access to information. You can call components from any script or programming language that supports Automation. XML is a meta-markup language that provides a format to describe structured data by using a set of tags.

ASP and VBScript

VBScript is the default scripting language for ASP. In VBScript, you use the percent sign with brackets as delimiters around the tags: <%example%>

You can put many tags inside one pair of VBScript delimiters:<%example, samples%>

ASP and Web Server

Server-side scripts run when a browser requests an .asp file from the Web server. ASP is called by the Web server, which processes the requested file from top to bottom and executes any script commands. It then formats a standard Web page and sends it to the browser.

The Active Server Pages feature of IIS 3.0 requires Microsoft Windows NT?Server 4.0 running IIS 2.0 or Windows NT Workstation 4.0 running Peer Web Services.

A simple example

<%@ Language=VBScript %>
<html>
<head>
<title>Example 1</title>
</head>
<body>
<%
FirstVar = "Hello world!"
%>
<%=FirstVar%>
</body>
</html>

see outcome

ASP and Database Server

Following is an example illustrating how ASP talks to a database server:

1.Creates an instance of an Active Server component
set objConn = server.createobject("ADODB.Connection")

2. Opens the connection to the data store (in this example, connects to the Access driver and Access database in the Inetpub directory where the database is saved)
strProvider = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\Inetpub\Wwwroot\Tutorial\guestbook.mdb;"
objConn.Open strProvider

3.Instantiate Command object and use ActiveConnection property to attach connection to Command object
set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = objConn

4.Define SQL query and execute it
cm.CommandText ="delete from table1"
cm.execute

ASP Database Example

This example describes how to develop a guest book application. Guest books allow visitors to your site a chance to give you feedback. Information such as the visitor’s name, e-mail address, and comments can be available to you.

Setting up the database

See source code

See Interface

Links

ASP Tutorials @ Webreference.com (*****)

ASP Online Tutorial (****)

Microsoft ASP Tutorial (****)

 

[Back to top]

 

 
Created by Jian-Qing Wu
Last modified: