diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-A96ABD2C-A338-58E5-A674-E840B1F53670.dita --- a/Symbian3/PDK/Source/GUID-A96ABD2C-A338-58E5-A674-E840B1F53670.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-A96ABD2C-A338-58E5-A674-E840B1F53670.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,56 +1,113 @@ - - - - - -Creating a User Defined Table: TutorialThis tutorial shows you how to create a user defined table. The tutorial, then shows you how to store a new record.

Before you start, you must understand:

  • the general concept of the Comms Database

  • the specific concepts of fields, records, links and tables

  • how to write and build application code to run on Symbian OS

This tutorial shows you:

  • how to create a user defined table

  • how to create a user defined record and store that record in the table

Make sure that you have created a session. Define a schema for the new table. Create an array of SGenericRecordTypeInfo items. Each SGenericRecordTypeInfo item defines a field in the record. const SGenericRecordTypeInfo recordInfo[] = - { - SGenericRecordTypeInfo(KCDTIdRecordName,EText,ENotNull,KCDTypeNameRecordName), - SGenericRecordTypeInfo(KCDTIdRecordTag,EUint32,ENoAttrs,KCDTypeNameRecordTag), - SGenericRecordTypeInfo(KCDTIdWLANServiceId,EUint32,ENoAttrs,KNameWLANServiceId), - SGenericRecordTypeInfo(KCDTIdWLANType,EUint32,ENoAttrs,KNameWLANType), - SGenericRecordTypeInfo(KCDTIdWLANEnabled,EBool,ENoAttrs,KNameWLANEnabled), - SGenericRecordTypeInfo(KCDTIdWLANPriority,EUint32,ENoAttrs,KNameWLANPriority), - SGenericRecordTypeInfo(0,0,ENoAttrs,KCDNull) - }; Define a name for the table. _LIT(KGenericTable,"MyGenericTable"); Create a CMDBGenericRecord object. A CMDBGenericRecord object represents a record and a set of records Give the object the name of the table and the name of the schema. ... -// Record factory creates the CMDBGenericRecord object. The KCDNewTableRequest value -// passed to the record factory allocates a new table Id. -CMDBGenericRecord* ptrNewTable = - static_cast<CMDBGenericRecord*>(CCDRecordBase::RecordFactoryL(KCDNewTableRequest)); - -// Initialise with the name of the table and the name of the schema. -ptrNewTable->InitialiseL(KGenericTable(),recordInfo); -... Access fields in the record. The code uses GetFieldByNameL() and GetFieldByIdL(). ... -TInt valueType; - -CMDBElement* LanType = ptrNewTable-> GetFieldByNameL(KNameWLANType, valueType); -CMDBElement* RecordName = ptrNewTable->GetFieldByIdL(KCDTIdRecordName); -... Change the valuie of the fields and create a new record. ... -// Cast the field objects to the appropriate type -CMDBField<TUint32>* LanTypefield = static_cast<CMDBField<TUint32>*>(LanType); -CMDBField<TDesC>* RecordNamefield = static_cast<CMDBField<TDesC>*>(RecordName); - -// Change the field value -*LanTypefield = 100; - -// Change the field value -_LIT(KNewName, " NewName "); -RecordNamefield->SetMaxLengthL(KNewName().Length()); -*RecordNamefield = KNewName(); - -// Can also use this format: RecordNamefield->SetL(KNewName()); - - -// Asks for a new record -ptrNewTable->SetRecordId(KCDNewRecordRequest); - -// Stores the new record -ptrNewTable->StoreL(*iDb); -...
Comms Database - concepts
\ No newline at end of file + + + + + +Creating +a User Defined Table: TutorialThis tutorial shows you how to create a user defined table. The +tutorial, then shows you how to store a new record. + + +

Before you start, +you must understand:

    +
  • the general concept +of the Comms Database

  • +
  • the specific concepts +of fields, records, links and tables

  • +
  • how to write and build +application code to run on Symbian platform

  • +
+

This tutorial shows +you:

    +
  • how to create a user +defined table

  • +
  • how to create a user +defined record and store that record in the table

  • +
+ +Make sure that you +have created a session. + +Define a schema +for the new table. + +Create an array of SGenericRecordTypeInfo items. +Each SGenericRecordTypeInfo item defines a field in the record. +const SGenericRecordTypeInfo recordInfo[] = + { + SGenericRecordTypeInfo(KCDTIdRecordName,EText,ENotNull,KCDTypeNameRecordName), + SGenericRecordTypeInfo(KCDTIdRecordTag,EUint32,ENoAttrs,KCDTypeNameRecordTag), + SGenericRecordTypeInfo(KCDTIdWLANServiceId,EUint32,ENoAttrs,KNameWLANServiceId), + SGenericRecordTypeInfo(KCDTIdWLANType,EUint32,ENoAttrs,KNameWLANType), + SGenericRecordTypeInfo(KCDTIdWLANEnabled,EBool,ENoAttrs,KNameWLANEnabled), + SGenericRecordTypeInfo(KCDTIdWLANPriority,EUint32,ENoAttrs,KNameWLANPriority), + SGenericRecordTypeInfo(0,0,ENoAttrs,KCDNull) + }; + +Define a name for +the table. +_LIT(KGenericTable,"MyGenericTable"); + +Create a CMDBGenericRecord object. + +A CMDBGenericRecord object represents +a record and a set of records + +Give the object the name of the table and the name of the schema. +... +// Record factory creates the CMDBGenericRecord object. The KCDNewTableRequest value +// passed to the record factory allocates a new table Id. +CMDBGenericRecord* ptrNewTable = + static_cast<CMDBGenericRecord*>(CCDRecordBase::RecordFactoryL(KCDNewTableRequest)); + +// Initialise with the name of the table and the name of the schema. +ptrNewTable->InitialiseL(KGenericTable(),recordInfo); +... + +Access fields in +the record. + +The code uses GetFieldByNameL() and GetFieldByIdL(). +... +TInt valueType; + +CMDBElement* LanType = ptrNewTable-> GetFieldByNameL(KNameWLANType, valueType); +CMDBElement* RecordName = ptrNewTable->GetFieldByIdL(KCDTIdRecordName); +... + +Change the valuie +of the fields and create a new record. +... +// Cast the field objects to the appropriate type +CMDBField<TUint32>* LanTypefield = static_cast<CMDBField<TUint32>*>(LanType); +CMDBField<TDesC>* RecordNamefield = static_cast<CMDBField<TDesC>*>(RecordName); + +// Change the field value +*LanTypefield = 100; + +// Change the field value +_LIT(KNewName, " NewName "); +RecordNamefield->SetMaxLengthL(KNewName().Length()); +*RecordNamefield = KNewName(); + +// Can also use this format: RecordNamefield->SetL(KNewName()); + + +// Asks for a new record +ptrNewTable->SetRecordId(KCDNewRecordRequest); + +// Stores the new record +ptrNewTable->StoreL(*iDb); +... + + +
+Comms Database + concepts +
\ No newline at end of file