Computer Corporation of America
|
Feedback
Search CCA:
   
USA CCA
CCA Products
CCA Customer Support
CCA Resources
CCA - Company
CCAPRINT: A Newsletter for Model 204® and System 1032® Users
March 10, 2001

ADO Interface with CCA client-server products

Incorporating Active Server Pages

By Steve Nelson

In this article we show how to use both the ADO Interface and Active Server Pages (ASP) interface, as well as the Remote Command Line (RCL) feature of Connect * , in a web development scheme. We examine how these two development environments can be used with Model 204 commands and User Language statements.

Note: With Connect* and web development, any web serving software can provide a single threaded environment for data access. Connect * is a single threaded DLL. Within IIS 4.0, once you create a virtual directory, you can select an option to run the application within a single threaded environment. We enabled this option.

Web-based monitoring of remote locations

We wanted our web pages project to help monitor remote locations. We made four Model 204 commands, MONITOR, LOGWHO, VIEW ALL, and VIEW VERSION, execute by clicking a button. The fifth button, COMMAND, invokes a text box where you can enter a Model 204 command, User Language statement, or call a procedure. All are processed within the web pages using the ADO Interface and ASP.

Figure 1 displays our home page with the five command buttons.

Figure 1. Remote Administration home web page

Getting started

To recreate this project you need:

Connect *
Web browser
IIS 4.0
Text editor

Virtual directory to access the ASP developed pages. See your web server document on creating virtual directories.

Displaying button output

Next, we created a common module called COMMAND.ASP where you can send specific commands and present the results. The code handles any statement given. Figure 2 is the generated output from a web browser using this ASP page.

Figure 2. Output from COMMAND.ASP

Writing the code behind the buttons

The COMMAND.ASP code accepts one parameter, or in web terms, a name/value pair. The name/value pair is called txtRCLcommand; see the red text in Figure 3. With a browser, the COMMAND.ASP accepts a string that looks like:

http://myserver/m204ra/command.asp?txtRCLcommand=VIEW ALL;

Figure 3. COMMAND.ASP code

<%@ language=vbscript %>

<%

dim szcommand

<-- Get the value from the name txtRCLCommand

szcommand = request("txtRCLcommand") & ";"

if szcommand <> "" then <-- Check for spaces

set rclconnect = createobject("adodb.connection") <-- Create connection object

set rcloutput = createobject("adodb.recordset") <-- Create record set object

rclconnect.open("dsn=m204rcl;uid=admin;pwd=admin;") <-- Open the connection

set rcloutput.activeconnection = rclconnect

rcloutput.cursortype = 3

rcloutput.open szcommand <-- Execute Statement

end if

%>

<html>

<head>

</head>

<body>

<form>

<center>

<% if szcommand <> "" then %>

<textarea cols="80" readonly rows="15" wrap="hard">

<%

do while not rcloutput.eof <-- Do until no more ouput

response.write rcloutput(0).value & vbcrlf <-- Write the data

rcloutput.movenext <-- Get more data

loop

%>

</textarea>

<% else %>

<p>no command available</p>

<% end if %>

</center>

<%

if szcommand <> "" then

rcloutput.close <-- Close the record set

rclconnect.close <-- Close the Connect

end if

%>

</form>

</body>

</html>

Entering your own commands

We also created a web page that accepts a command which is not handled by the other buttons. We called this web page commandline.htm; it has an input box for entering an RCL or User Language command and a Submit button. Figure 4 shows the text box with a MONITOR USERS command entered.

Figure 4. After pressing the COMMAND button

The text that is entered in the text box passes the name/value pair named txtRCLcommand to the ASP page, COMMAND.ASP, as a string, for example, txtRCLcommand=MONITOR USERS. The name is txtRCLcommand; the value is MONITOR USERS.

The name of the input box must be the same as the name/value pair called txtRCLCommand within COMMAND.ASP. Figure 5 is the HTML code for commandline.htm. Notice the name of the input box highlighted in red.

Figure 5. Code for commandline.htm

<html>

<head>

</head>

<body bgcolor="#FFFFFF">

<form method="post" action="command.asp" >

<div align="center"><font face="Verdana"><b>Enter a command</b></font>

<input type="text" name="txtRCLCommand" size="80" maxlength="255">

<input type="submit" value="Submit" id=submit1 name=submit1>

</div>

</form>

</body>

</html>

We entered a MONITOR USERS command, which provides output. When we press Submit the output is similar to that displayed in Figure 6.

Figure 6. Output of MONITOR USERS command

Putting the application together

To tie all of the mentioned commands together to produce a complete web site for remote administration, we used two HTML files: default.htm, shown in Figure 7, and header.htm, shown in Figure 8. The web page that begins the application is frame-based default.htm.

Figure 7. Code for default.htm

<html>

<head>

<title>Model 204 Remote Administration</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<frameset rows="129,359*" frameborder="NO" border="0" framespacing="0" cols="*">

<frame name="topFrame" scrolling="NO" noresize src="header.htm" >

<frame name="mainFrame" src="Output.htm">

</frameset>

<noframes><body bgcolor="#FFFFFF">

</body></noframes>

</html>

With the code in default.htm, we create two frames. The first frame is for header.htm, shown in Figure 8, which is used for navigation.

Figure 8. Code for header.htm

<html>

<head>

<title>Model 204 Remote Commands</title>

</head>

<body>

<form>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td bgcolor="#333366">

<img src="header.gif" width="600" height="100" usemap="#commap" border="0">

<map name="commap">

<area shape="rect" coords="170,70,244,94"
href="command.asp?txtRCLCommand=MONITOR%20ALL" target="mainFrame">

<area shape="rect" coords="251,71,324,93" href="command.asp?txtRCLCommand=LOGWHO" target="mainFrame">

<area shape="rect" coords="331,70,404,95"
href="command.asp?txtRCLCommand=VIEW%20ALL" target="mainFrame">

<area shape="rect" coords="411,71,483,94"
href="command.asp?txtRCLCommand=VIEW%20VERSION" target="mainFrame">

<area shape="rect" coords="491,70,563,95" href="commandline.htm" target="mainFrame">

</map>

</td>

<td>&nbsp;</td>

</tr>

</table>

</form></body></html>

Summing it up

You can change or enhance this application.

Coming attractions

In our next article we plan to use Microsoft Office products with Model 204 and System 1032 data.

 

Copyright © 2008 Computer Corporation of America.
All right reserved. Published in the United States of America.

Contact CCA Webmaster
Copyright 2008