Properties in the dbDAO classes are defined differently from the way they are defined in Visual Basic. The PropName type library property, for example, is exposed as two methods: GetPropName and SetPropName. If the property is read-only, only the Get method is exposed. If the property is write-only, only the Set method is exposed. The Get method takes no arguments and returns the value of the property, using the appropriate C data type where possible. The Set method takes a single argument — the new value to which you want to set the property — again using the appropriate C data type where possible.
One example of a read/write property is the Name property. It is mapped to the GetName and SetName methods. Therefore, its C prototypes are as follows:
CString GetName (VOID); VOID SetName (LPCTSTR pstr);
Some properties return data of various types. The most obvious of these are the Value properties of Field objects. These have to return variants because the data type of the return value isn’t known until run time.
Visual Basic has default properties. For example, the following code:
a = rst!FirstName
is equivalent to:
a = rst!FirstName.Value
Here, Value is the default property of the Field object. Because C++ has no equivalent syntax, you have to ask for the default property by name:
a = rst.Fields["FirstName"].GetValue();
Note For this particular call, the performance of this code could be improved by using the dbDAO GetField method, as follows:
a = rst.GetField("FirstName");