About the FoundTitle Object

FoundTitle objects are also private objects. Each FoundTitle object represents one row in the database that matches the search criteria, and contains the following properties. These properties are from columns in the returned recordset.

FoundTitle property Description
IsReviewed Enumeration, specifying the state of the critique of this title by this reviewer (no critique has been submitted, a critique is in process, the critique has been approved)
MediaType Enumeration, specifying media type (book, audio/video, periodical, software)
Title Title of the library item
Authors Concatenated list of authors
BibNo Identity of the item in the FmLib database
Published Date on which the library item was published

CML/LitCrit uses a new middle-tier component, specifically a method added to the Search component of the original CML application. Its purpose is to search for a library title, using the values input for media type, authors, title, and bibno simultaneously, and return a recordset. This differs from CML functionality in that searching on all these attributes occurs at the same time, and no temporary tables are created in the database.

Also, this is a stateless component because RDS cannot invoke a component with state.

The rows that are returned (individual items in the collection object) are displayed in the bottom half of the Choose Title dialog box. When a user clicks one, the ChooseTitle method copies (ByRef) the item title, authors, and bibno onto the main LitCrit form. Alternatively, if you've already reviewed this item, ChooseTitle displays a message to that effect. Finally, after the search is successful and all requested data is returned and copied onto the form, ChooseTitle makes that area of the form read-only.

Why FoundTitles is a Collection Object

The ChooseTitle method invokes a container object for the search results. The container then receives and holds the individual objects resulting from the search. This container object invokes RDS, using search strings that the user has typed, strings that are appropriate for conducting a full-text search. This search in turn invokes an RDS customization handler. The ChooseTitle call returns results from the SQL Server database in a recordset.

Recordsets are most useful for working with data one record at a time — for example, you can cache the recordset and then work with its individual records if you request them by index. But you can work more flexibly with collections of objects. In this case, the F & M developers preferred to work with data in a For Each loop, and the only way to do this is with the built-in Collection object.

Another advantage of using a collection is that you can use IntelliSense in Microsoft Visual Basic® or Microsoft Visual Studio®. This tool helps programmers by automatically recognizing objects' properties and presenting them visually, so that they are easier to work with.

For Each and NewEnum

For Each uses a hidden interface called NewEnum. Using Visual Basic, you cannot define a NewEnum interface, but the Collection object (in contrast to a recordset) offers one automatically. In this data retrieval process, rows are passed back from the RDS search and it is these rows that are enumerated. In other words, first the application creates a collection, and makes a request, and then rows are retrieved and added individually to the FoundTitles collection as objects.

When requested to do a For Each, the application passes the NewEnum operator of the collection, and client code in ChooseTitle loops through it using the For Each operator. This lets the application release the recordset after it has been passed back.

It is also possible to use ADO directly instead of RDS to perform this query. But after the application has received a recordset, enumerated everything in it, and put its contents into a collection object, it would not benefit from typical RDS advantages like asynchronous operation, client-side caching of results, the ability to loop forward or back through the recordset, and sorting and searching.

An additional advantage of using RDS is that it lets you invoke a middle-tier component. In the case of CML/LitCrit, this component is the Search component of CML.

Although the original CML application used RDS and not just ADO, it did not take advantage of RDS handler objects. For more information, see About RDS Customization Handlers.