CreateProperty Method

See Also    Example    Applies To

Creates a new user-defined CdbProperty object (Microsoft Jet workspaces only).

Syntax

CdbPropertyCreateProperty(LPCTSTR pstrName = NULL,

LONG lType = -1,

LPVARIANT pvValue = NULL,

BOOL bDDL = FALSE);

Parameters

Type Argument Description
LPCTSTR pstrName Optional. A pointer to a string that uniquely names the new CdbProperty object. See the Name property for details on valid property names.
LONG lType Optional. A constant that defines the data type of the new CdbProperty object. See the Type property for valid data types.
LPVARIANT pvValue Optional. A pointer to a Variant containing the initial property value. See the Value property for details.
BOOL bDDL = FALSE Optional. A Boolean that indicates whether or not the CdbProperty is a DDL object. If TRUE, users can't change or delete this CdbProperty object unless they have dbSecWriteDef permission.

Remarks

You can create a user-defined CdbProperty object only in the Properties collection of an object that is persistent.

If you omit one or more of the optional parts when you use CreateProperty, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its property settings. See the Name, Type, and Value property topics for more details.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a user-defined CdbProperty object from the collection, use the Delete method on the Properties collection. You can't delete built-in properties.

Note If you omit the DDL argument, it defaults to False (non-DDL). Because no corresponding DDL property is exposed, you must delete and re-create a CdbProperty object you want to change from DDL to non-DDL.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbDatabase      dbs;
CdbProperty      prop;
COleVariant      vVal(FALSE, VT_BOOL);
      
// Initialize dbs, etc.
// Create a property that says whether this database contains 
// information that must be reported quarterly.

dbs  = dben.OpenDatabase(...);
prop = dbs.CreateProperty(_T("QuarterlyReportRequired"),
               dbBoolean, &vVal, FALSE);
dbs.Properties.Append( prop );  // Append property.