Call this member function to add a field to the table.
void CreateField( LPCTSTR lpszName, short nType, long lSize, long lAttributes = 0 ); void CreateField( CDaoFieldInfo& fieldinfo );
A pointer to a string expression specifying the name of this field.
A value indicating the data type of the field. The setting can be one of these values:
1 – 255
A value that indicates the maximum size, in bytes, of a field that contains text, or the fixed size of a field that contains text or numeric values. The lSize parameter is ignored for all but text fields.
A value corresponding to characteristics of the field and that can be combined using a bitwise-OR.
The field size is fixed (default for Numeric fields).
The field size is variable (Text fields only).
The field value for new records is automatically incremented to a unique long integer that cannot be changed. Only supported for Microsoft Jet database tables.
The field value can be changed.
The field is sorted in descending (Z – A or 100 – 0) order (applies only to a Field object in a Fields collection of an Index object). If you omit this constant, the field is sorted in ascending (A – Z or 0 – 100) order (default).
A reference to a CDaoFieldInfo structure.
A DAOField (OLE) object is created and appended to the Fields collection of the DAOTableDef (OLE) object. Besides its use for examining object properties, you can also use CDaoFieldInfo to construct an input parameter for creating new fields in a tabledef. The first version of CreateField is simpler to use, but if you want finer control, you can use the second version of CreateField, which takes a CDaoFieldInfo parameter.
If you use the version of CreateField that takes a CDaoFieldInfo parameter, you must carefully set each of the following members of the CDaoFieldInfo structure:
The remaining members of CDaoFieldInfo should be set to 0, FALSE, or an empty string, as appropriate for the member, or a CDaoException may occur.
For related information, see the topic "CreateField Method" in DAO Help.