MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 6: Getting and Setting Data
To set data—for example, with IRowsetChange::SetData for rowset data or ICommand::Execute for input parameter data—the consumer must perform the following actions:
For each column or input parameter specified in the accessor, the consumer performs the following actions. When passing key values to an index rowset, the consumer performs these actions only for the number of key columns specified in the cKeyValues argument in IRowsetIndex::Seek or in the cStartKeyValues or cEndKeyValues arguments in IRowsetIndex::SetRange.
Note This procedure assumes that the consumer has bound the value, length, and status for each column or input parameter. If any of these are not bound, the actions to be performed are the same except that the consumer does not set the unbound part.
If the provider is to use the default as the input value for an input or input/output parameter in a procedure, or if the provider updates the column, the consumer sets the status to DBSTATUS_S_DEFAULT and proceeds to the next column or input parameter.
If the provider is to ignore this column in performing an insert or update, the consumer sets the status to DBSTATUS_S_IGNORE.
Otherwise, the consumer sets the status to DBSTATUS_S_OK.
The address where the status value is stored is calculated from the buffer address passed to the method and the obStatus element of the binding.
For all other data types, the provider ignores the length, so the consumer does not need to set it.
For each column or input parameter specified in the accessor, the provider performs the following actions. When passing key values to an index rowset, the provider performs this procedure only for the number of key columns specified in the cKeyValues argument in IRowsetIndex::Seek or in the cStartKeyValues or cEndKeyValues arguments in IRowsetIndex::SetRange. This procedure assumes that the consumer has bound the value, length, and status for each column or input parameter. If any of these are not bound, the procedure is the same except that the provider does not attempt to retrieve the unbound part from the consumer's buffer. For more information, see "Binding Data Values," earlier in this chapter.
If the status is any other value, the provider sets the status to DBSTATUS_E_BADSTATUS and proceeds to the next column or input parameter.
The address from which the status value is retrieved is calculated from the buffer address passed to the method and the obStatus element of the binding.
For all other data types, the provider ignores the length. The address from which the length value is retrieved is calculated from the buffer address passed to the method and the obLength element of the binding.
If the type indicator is DBTYPE_IUNKNOWN or DBTYPE_IDISPATCH, the provider retrieves a pointer to an interface on the object from the consumer's buffer. For information about how the provider retrieves the object itself, see Chapter 7, "BLOBs and COM Objects."
If the type indicator is DBTYPE_BSTR, the provider retrieves the pointer to the BSTR from the consumer's buffer and the BSTR itself from the memory to which this pointer points. The provider ignores cbMaxLen. That is, it does not truncate the BSTR to cbMaxLen bytes.
Note It is an error to combine DBTYPE_BYREF and DBTYPE_BYTES with no bound length.
If an error occurs while converting the data, the provider sets the status accordingly and proceeds to the next column or output parameter. For a list of status values that describe conversion errors, see "Status Values Used When Setting Data" in "Status," earlier in this chapter. For more information about converting data, see "Data Type Conversion Rules" in Appendix A, "Data Types."
If the provider encounters an error while retrieving a column or input parameter value, it sets the status value of that column or input parameter. Depending on the provider, it also does one of the following:
If the provider stops processing, it must set the status value to DBSTATUS_E_UNAVAILABLE for any column or input parameter that was not in error and was not successfully set. Thus, the consumer can determine which column or input parameter values were valid, which were invalid, and which were not validated.
When setting column data, except when searching for a key value or setting the index range, the provider then produces one of the following return codes:
When setting input parameter data, searching for a key value, or setting the index range, the provider then returns DB_E_ERRORSOCCURRED.