Chapter 12 Calling EAServer Component Methods from PowerDynamo


Working with ADO record sets as PowerDynamo query objects

When a Dynamo script calls an EAServer component through ActiveX and that component returns a result set, an ADO record set is returned. ADO record sets have different properties and methods than the Dynamo query object. Dynamo includes a script called adoqry.ssc that is installed in the system/utils folder of the Dynamo Web site. This script implements a class called ADOQuery which takes as a parameter an ADO record set object sent by EAServer, and returns a class that has methods mimicking those of a Dynamo query object.

Scripts that call an EAServer component through ActiveX and do not make use of the ADOQuery class look something like this:

comp = CreateObject( "SVU.SVUEnrollment" );
comp.Initialize();
// returns ADO RecordSet-like object
query = comp.getMajors();
query.MoveFirst();
columns = query.Fields.Count;
document.writeln( "There are " + columns + " columns" );
while( !query.EOF ) {
    fields = query.Fields;
    for( j = 0; j < columns; j++ ) {
        field = fields.Item(j);
        value = field.Value;
        document.writeln( value );
    }
    query.MoveNext();
}

With the ADOQuery class, you could instead do this:

import ~/system/utils/adoqry.ssc;

comp = CreateObject( "SVU.SVUEnrollment" );
comp.Initialize();
// returns ADO RecordSet-like object
query = comp.getMajors();
// wrap up the ADO RecordSet to mimic a Dynamo query 
// object
dynQuery = new ADOQuery( query );
columns = dynQuery.GetColumnCount();
document.writeln( "There are " + columns + " columns" );
while( dynQuery.MoveNext() ) {
    for( j = 1; j <= columns; j++ ) {
        value = dynQuery.GetValue(j);
        document.writeln( value );
    }
}

 


Copyright © 2001 Sybase, Inc. All rights reserved.