Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
191
Добавлен:
11.05.2015
Размер:
4.96 Mб
Скачать

Crystal Data Source Type Library

The Crystal Data Source Type Library is a COM interface type library that can be implemented in your own Visual Basic classes. One the interface has been added to a class, you must implement every method and property defined by the interface. This process requires extensive Visual Basic coding, but the result is a complete data source that can be used much like other ActiveX data sources such as ADO or DAO. Additionally, a data source defined using the Crystal Data Source Type Library can be passed to report files at runtime through the Active Data Driver, Volume 1, Chapter 5, allowing dynamic runtime reporting on powerful customized data sources.

Possible uses for data sources defined using the Crystal Data Source Type Library are ActiveX style data sources, similar to ADO, DAO, and RDO, Business Objects and business rules components, Microsoft Transaction Server components, or instrumentation systems that produce dynamic real-time data.

Note that as a type library, the Crystal Data Source Type Library does not actually provide any functionality on its own. You must determine the actual functionality by implementing each of the properties and methods defined in the type library interface. The descriptions given here of the CRDataSource object, its properties, and its methods are intended as a guideline for the type of functionality you should define in your own classes.

CRDataSource

CRDataSource is a COM interface rather than an actual COM object. By writing code for each of the CRDataSource methods and properties in your own code, your class or COM component implements the CRDataSource interface and, therefore, becomes the actual Crystal Data Source.

To implement CRDataSource in a Visual Basic class, use the following code in the General Declarations section of your class module:

Implements CRDataSourceLib.CRDataSource

Once implemented, CRDataSource will appear as an available object in your class module. You must add code for every property and method of the CRDataSource object to correctly implement the Crystal Data Source interface. For more information, see Crystal Data Source Type Library, Volume 1, Chapter 5.

The following topics are discussed in this section.

CRDataSource Properties, Page 135

CRDataSource Methods, Page 138

CRDataSource Properties

The Crystal Data Source interface defines the following properties. An example of each property follows the property description.

Bookmark, Page 136

EOF, Page 136

FieldCount, Page 136

Crystal Data Source Object Models

135

FieldName, Page 137

FieldType, Page 137

FieldValue, Page 137

RecordCount, Page 138

Bookmark

Used to obtain a bookmark (identifier) for a particular record in the Recordset, or to move to the record identified by the bookmark. To simplify the process of navigating to a particular record over and over again, you can save a bookmark for the record in a variable, then quickly return to that record by assigning the value of the variable to the Bookmark property.

Example

Dim aBookmark As Variant

aBookmark = myCRDataSource.CRDataSource_Bookmark

Move around in the Recordset performing various operations

To return to the bookmarked record: myCRDataSource.CRDataSource_Bookmark = aBookmark

EOF

Read only.

This property indicates whether or not the current record is the last record in the Recordset. The value of the EOF property is True if the current record is the last record, False otherwise.

Example

If myCRDataSource.CRDataSource_EOF = True Then myCRDataSource.CRDataSOurce_MoveFirst

End If

FieldCount

Read only.

This property returns the number of fields in the Recordset.

Example

Dim numFields as Integer

numFields = myCRDataSource.CRDataSource_FieldCount

Crystal Data Source Object Models

136

FieldName

Read only.

Returns the name of a specific field as indicated by the field index. Field indexes for the Crystal Data Source interface start with 1 for the first field, 2 for the second, etc.

Example

Dim firstField As String Dim secondField As String

firstField = myCRDataSource.CRDataSource_FieldName 1 secondField = myCRDataSource.CRDataSource_FieldName 2

FieldType

Read only.

Obtains a Visual Basic VarType constant indicating the type of data stored in a particular field. Fields are identified using field indexes. Field indexes for the Crystal Data Source interface start with 1 for the first field, 2 for the second, etc.

Example

Dim fieldType As Integer

fieldType = myCRDataSource.CRDataSource_FieldType 1 If fieldType = vbString Then

’ Do something with the string data in this field End If

FieldValue

Obtains the data actually stored in the field for the current record. Fields are identified using field indexes. Field indexes for the Crystal Data Source interface start with 1 for the first field, 2 for the second, etc.

Example

Dim fieldVal As Variant

fieldVal = myCRDataSource.CRDataSource_FieldValue 2

Crystal Data Source Object Models

137

Соседние файлы в папке crystal