DataB

Purpose
This property can be used to read, update, or append a record in the database. It provides a convenient and intuitive way to manipulate records using keys as the primary form of access.

Syntax (Read/Write Property)
(Read) Data = object.Data(Key)
(Write)
object.
Data(Key) = Data

Parameters (Read)
Key (String)   This is the key of the record you want to retrieve data from.
Data (Byte Array)   This is the data that is retrieved from the record specified by Key.

Parameters (Write)
Key (String)   This is the key of the record you want to assign data to.
Data (Byte Array)   This is the data you want to assign to the record specified by Key.

Notes (Read)
This property allows you to retrieve data from a specified record.

If a record with the specified key already exists: (1) The data associated with the specified record is returned as a string. (2) The ErrorNumber property returns rtCDP_ErrNoError.

If a record with the specified key does not already exist: (1) Function returns a zero-length string (""). (2) The ErrorNumber property returns rtCDP_ErrRecordNotFound.

If any errors occur, the function returns a zero-length string ("").

Notes (Write)
This property allows you to update records and append records to the database.

If a record with the specified key already exists: (1) The data associated with the record is updated to contain the specified data. (2) The ErrorNumber property returns rtCDP_ErrNoError.

If a record with the specified key does not already exist: (1) Then a new record is added to the end of the database. It is given the name specified in the Key parameter, and the data specified in the Data parameter. (2) The ErrorNumber property returns rtCDP_ErrNoError.

If multiple records with the specified key already exist: (1) The data associated with the first occuring record (the one with the lowest record number) is updated to contain the specified data. (2) The ErrorNumber property returns rtCDP_ErrNoError.

If any errors occur, no records are changed.

Error Values (Read)
After reading this property, the property ErrorNumber will report one of the following values:

rtCDP_ErrNoError
rtCDP_ErrKeyTooLong
rtCDP_ErrRecordNotFound

Error Values (Write)
After writing this property, the property ErrorNumber will report one of the following values:

rtCDP_ErrNoError
rtCDP_ErrKeyTooLong
rtCDP_ErrDataTooLong
rtCDP_ErrDatabaseFull

Example
Objective: First write, then read some records from the database using the DataB property.

'Create a database
Dim CDP As rtCDP.rtCompactDataPak
Set CDP = New
rtCDP.rtCompactDataPak
'Add some records to the database
Dim dbData() As Byte: ReDim dbData(3)
dbData(0) = Asc("H")
dbData(1) = Asc("o")
dbData(2) = Asc("m")
dbData(3) = Asc("e")
CDP.DataB("Name") = "Amanda"
CDP.DataB("Address") =
dbData

This is the current state of the database:

Rec Key Data
0 Name Amanda
1 Address Home

'Now, retrieve the "Name" record
Dim dbName() As Byte
dbName = CDP.DataB("Name")
'dbName equals "Amanda"

Version History
(Read) 1.0 2/1/2001 Tested
(Write) 1.0 2/1/2001 Tested

See Also
Data, DataArray, DataArrayB, DataRec, DataRecB