With CPDB, you can dynamically create a structured database and add, modify or remove the records which it contains. Usually, these treatments requires tens of lines of code.
Here an example which shows with which facility you can create a CPDB database:
// Create user base Err errNo; if (!CPDB_DatabaseExist("USERS")) { errNo = CPDB_CreateDatabase(0, "USERS", 'CPDB', "NUM=INT;NAME=STRING[20];SURNAME=STRING[20];GROUP=SHORTINT"); } |
The data base is thus created in only one line of code.
The mask of description is described in detail in the documentation of CPDB_CreateDatabase.
The addition of a record is carried out in only one line of code :
// Create a new record Err errNo; errNo = CPDB_AddRecord(handle); |
The variable "handle" corresponds to the handle of a beforehand open database.
If no record had been read previously, then a blank recording is created, if not, the new record is a copy of the currently record readed (or modified).
To be sure to create a blank record use function CPDB_Clear.
To delete a record, use the fonction CPDB_DeleteRecord.
The fields of a record can by the use of the functions CPDB_WriteShortInt, CPDB_WriteInt, CPDB_WriteLongInt et CPDB_WriteString.
Once the modified fields, the record should either be updated by CPDB_updateRecord, or to create a new record by CPDB_AddRecord.
Err errNo;
// Update the fields of a record CPDB_Clear(handle); errNo = CPDB_WriteInt(handle, "NUM", iNum); errNo = CPDB_WriteString(handle, "NAME", sName); errNo = CPDB_WriteShortInt(handle, "GROUP", iGroup);
if ( bAddMode ) { // Create a new record errNo = CPDB_AddRecord(handle); } else { // Modification of the current record errNo = CPDB_UpdateRecord(handle); }
|
CPDB_AddRecord
CPDB_CreateDatabase
CPDB_WriteShortInt
CPDB_WriteInt
CPDB_WriteLongInt
CPDB_WriteString
CPDB_UpdateRecord
CPDB_Clear
CPDB_DeleteRecord
Creation date : 01/10/2003 @ 06:41
Last update : 01/10/2003 @ 07:31
Category : CPDB library
Page read 9768 times
|