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

Example

Dim numRows As Long

numRows = cdoRowset.RowCount

CrystalComObject Methods

The CrystalComObject uses the following methods. These methods each have a section describing their parameters and returns, followed by an example.

AddField, Page 129

AddRows, Page 130

DeleteField, Page 130

GetColCount, Page 131

getEOF, Page 131

GetFieldData, Page 132

GetFieldName, Page 132

GetFieldType, Page 133

MoveFirst, Page 133

MoveNext, Page 134

MoveTo, Page 134

Reset, Page 134

AddField

Function AddField(FieldName As String, [FieldType]) As Boolean

Use this method to add fields to a rowset before adding data. The rowset must have fields defined before data can be added using the AddRows method.

Parameters

FieldName

A string value specifying the name of the field.

FieldType

An optional value specifying the data type that will be contained in this field. Use Visual Basic VarType constants to specify the data type. If this value is omitted, the vbVariant type will be used.

Crystal Data Source Object Models

129

Returns

A Boolean value indicating whether or not the field was successfully added to the Rowset.

Example

cdoRowset.AddField "Order ID", vbString cdoRowset.AddField "Company Name", vbString cdoRowset.AddField "Order Amount", vbCurrency

AddRows

Sub AddRows(RowData)

Use this method to assign an array of data to the CDO Rowset.

Parameters

RowData

A standard Visual Basic two-dimensional array. The first dimension specifies the number of rows in the Rowset, while the second dimension specifies the number of fields for each row. A one-dimensional array is used to add a single row with multiple fields. When this array is dimensioned, it must be defined As Variant. For example:

Dim Rows(12, 4) As Variant

This example creates an array that will hold 12 rows with 4 fields. You must assign data to all cells in the array before assigning the array to the Rowset using AddRows.

Example

cdoRowset.AddRows Rows

DeleteField

Function DeleteField(FieldName As String) As Boolean

This method removes an existing field from the Rowset. If the field contains any data, that data is lost.

Parameters

FieldName

The name of the field you want to delete from the Rowset.

Crystal Data Source Object Models

130

Returns

A Boolean value indicating whether or not the field was successfully deleted. If the field does not exist, this function will return False.

Example

cdoRowset.DeleteField "Company Name"

GetColCount

Function GetColCount() As Integer

This function returns the number of columns or fields currently in the Rowset.

Returns

An integer value indicating the number of fields in the Rowset.

Example

Dim numFields As Integer numFields = cdoRowset.GetColCount

getEOF

Function getEOF() As Boolean

Use this function to determine if the current row in the Rowset is the last row.

Returns

True if the current row is the last row in the Rowset. False if the current row is anywhere else in the Rowset.

Example

If cdoRowset.getEOF Then cdoRowset.MoveFirst

End If

Crystal Data Source Object Models

131

GetFieldData

Function GetFieldData(column As Integer)

This method obtains the current value of a specific column in the Rowset for the currently selected row.

Parameters

column

A number indicating which field (column) of the row you want the current value of. Rowset columns, like array dimensions, are 0 based. The first column is 0, the second is 1, etc.

Returns

A variant value that contains the data for the specified field of the current row.

Example

Dim fieldData As Variant

fieldData = cdoRowset.GetFieldData 0

GetFieldName

Function GetFieldName(column As Integer) As String

Returns the name of the specified field (column). Field names are assigned using AddField, Page 129.

Parameters

column

A number indicating which field (column) of the Rowset you want the name of. Rowset columns, like array dimensions, are 0 based. The first column is 0, the second is 1, etc.

Returns

A string containing the name of the specified field.

Example

Dim secondField As String

secondField = cdoRowset.GetFieldName 1

Crystal Data Source Object Models

132

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