Purpose
Used to insert a new record into the database.
Syntax (Method)
object.Insert
Key, Data, KeyBefore
| Key
(String) |
|
The
new record's key is assigned this value. |
| Data
(String) |
|
The
new record's data is assigned this value. |
| KeyBefore
(String) |
|
The
new record is inserted just before the existing record containing
this key. |
Notes
This method allows duplicate keys to exist in the database.
Hence, if this method is called with a key (Key)
that already exists in the database, a new record will still be
inserted with the specified key (Key).
Error
Values
After calling this method, the property ErrorNumber
will report one of the following values:
rtCDP_ErrNoError
rtCDP_ErrKeyTooLong
rtCDP_ErrDataTooLong
rtCDP_ErrRecordNotFound
rtCDP_ErrDatabaseFull
Example
Objective:
Insert some records into the database.
'Create
the object
Dim CDP As
rtCDP.rtCompactDataPak
Set CDP = New
rtCDP.rtCompactDataPak
'Append a new record
CDP.Append "Name", "Melissa"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
Name |
Melissa |
'Insert
a new record
CDP.Insert "Tall", "Susan", "Name"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
Tall |
Susan |
| 1 |
Name |
Melissa |
'Insert
a new record
CDP.Insert "Older", "Debbie", "Name"
This
is the current state of the database:
| Rec |
Key |
Data |
| 0 |
Tall |
Susan |
| 1 |
Older |
Debbie |
| 2 |
Name |
Melissa |
'Insert
a new record
CDP.Insert "Younger", "Tina", "Fair"
'The
database is unchanged because "Fair" does not exist
'In
this case, ErrorNumber returns rtCDP_ErrRecordNotFound
Version
History
1.0 1/30/2001 Tested
See
Also
InsertB,
InsertArray, InsertArrayB, InsertRec, InsertRecB