MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 14: Properties
To set property values, a consumer must perform the following actions:
If the provider cannot satisfy a required property, it fails to create the object to which the property applies and the object-creation method returns DB_E_ERRORSOCCURRED. If the provider cannot set the value of an optional property, it creates the object to which the property applies and the method returns DB_S_ERRORSOCCURRED.
If the property belongs to the Rowset property group and applies to a single column, the consumer sets the colid element of the DBPROP structure to the ID of the column. Otherwise, the consumer sets the value of colid to DB_NULLID.
Note In cases where the colid element in the DBPROP structure for specified properties is ignored, the consumer must nevertheless set the value of colid to DB_NULLID. Not to do so is a programming error.
For example, assume that the consumer wants to set values for five properties, where properties 1, 2, and 3 are in property set A and properties 4 and 5 are in property set B. The consumer uses the structures shown in the following illustration.
An example of setting property values
The following table lists methods consumers can call to set property values.
Property group | Methods used to set property values |
Column | ITableDefinition::CreateTable |
Data Source | IDBProperties::SetProperties |
Data Source Creation | IDBDataSourceAdmin::CreateDataSource |
Data Source Information | IDBProperties::SetProperties |
Initialization | IDBProperties::SetProperties, IDBDataSourceAdmin::CreateDataSource |
Index | IIndexDefinition::CreateIndex |
Rowset | IColumnsRowset::GetColumnsRowset, ICommandProperties::SetProperties, IDBSchemaRowset::GetRowset, IOpenRowset::OpenRowset, ISourcesRowset::GetSourcesRowset, ITableDefinition::CreateTable |
Session | ISessionProperties::SetProperties |
Table | ITableDefinition::CreateTable, IAlterTable::AlterTable |
Note Read-only properties can always be set to their default values or to VT_EMPTY. Setting read-only properties to any other values will cause an error.
The return code generated by a property-setting method indicates how far the method has succeeded. Whether a success (S_) or an error (E_) return code is generated depends on factors such as whether the properties that failed to be set were required and on whether the method is SetProperties or a method that performs other actions in addition to setting properties. These factors are summarized in the following table.
Success or failure case | Return code: SetProperties | Return code: other methods |
All properties are optional, and all are set successfully. | S_OK | S_OK |
All properties are optional, and one or more (but not all) fail to be set. | DB_S_ERRORSOCCURRED | DB_S_ERRORSOCCURRED |
All properties are optional, and all fail to be set. | DB_E_ERRORSOCCURRED | DB_S_ERRORSOCCURRED |
All properties are required, and all are set successfully. | S_OK | S_OK |
All properties are required, and one or more (but not all) fail to be set. | DB_S_ERRORSOCCURRED | DB_E_ERRORSOCCURRED |
All properties are required, and all fail to be set. | DB_E_ERRORSOCCURRED | DB_E_ERRORSOCCURRED |
Not all properties are required, and all are set successfully. | S_OK | S_OK |
Not all properties are required, all required properties are set successfully, and one or more optional properties fail to be set. | DB_S_ERRORSOCCURRED | DB_S_ERRORSOCCURRED |
Not all properties are required, and one or more (but not all) required properties fail to be set. | DB_S_ERRORSOCCURRED | DB_E_ERRORSOCCURRED |
Not all properties are required, and all fail to be set. | DB_E_ERRORSOCCURRED | DB_E_ERRORSOCCURRED |