IConvertType::CanConvert

Gives information about the availability of type conversions on a command or on a rowset.

HRESULT CanConvert (
   DBTYPE                  wFromType,
   DBTYPE                  wToType,
   DBCONVERTFLAGS   dwConvertFlags);

Parameters

wFromType

[in]
The source type of the conversion.

wToType

[in]
The target type of the conversion.

dwConvertFlags

[in]
Whether CanConvert is to determine if the conversion is supported on the rowset or on the command. These flags have the following meaning:

Value Description
DBCONVERTFLAGS_
COLUMN
CanConvert is to determine if the conversion is supported when setting, getting, finding, filtering, or seeking on columns of the rowset. This flag is mutually exclusive with DBCONVERTFLAGS_PARAMETER.
DBCONVERTFLAGS_ISFIXEDLENGTH CanConvert is to determine a fixed length value of the DBTYPE specified in the dwFromType can be converted to the DBTYPE specified in wToType.  This flag can coexist with either DBCONVERTFLAGS_COLUMN or DBCONVERTFLAGS_PARAMETER.  This flag is only supported by OLE DB version 2.0 or greater providers.
DBCONVERTFLAGS_
ISLONG
CanConvert is to determine if the long version of the DBTYPE specified in the dwFromType can be converted to the DBTYPE specified in wToType. This flag is only valid when used in conjunction with a variable-length DBTYPE. This flag can coexist with either DBCONVERTFLAGS_COLUMN or DBCONVERTFLAGS_PARAMETER. This flag is only supported by OLE DB version 2.0 or greater providers.
DBCONVERTFLAGS_
PARAMETER
CanConvert is to determine if the conversion is supported on the parameters of the command.
DBCONVERTFLAGS_
FROMVARIANT
The DBTYPE specified in the wFromType represents a type within a VARIANT. CanConvert returns whether the conversion from a VARIANT of that type to the type specified in wToType is allowed.

Return Code

S_OK

The requested conversion is available.

S_FALSE

The requested conversion is not available.

wFromType or wToType were not valid types for the provider, and the provider was a version 2.0 or greater provider.

E_FAIL

A provider-specific error occurred.

E_INVALIDARG

The provider was an OLE DB 1.x provider and wFromType or wToType was not a valid type indicator for OLE DB 1.x .

DB_E_BADCONVERTFLAG

dwConvert flags was invalid.

The method was called on a command and its flags inquired about a conversion on a rowset, but the property DBPROP_ROWSETCONVERSIONSONCOMMAND was VARIANT_FALSE.

The DBCONVERTFLAG_PARAMETER bit was set and CanConvert was called on a rowset.

The DBCONVERTFLAGS_PARAMETER bit was set and CanConvert was called on a command (whether from a provider or not) that does not support parameters.

DBCONVERTFLAGS_ISLONG was specified, and the DBTYPE specified in dwFromType was not a variable-length DBTYPE.

DBCONVERTFLAGS_ISLONG was specified, and the provider was an OLE DB 1.x provider.

DBCONVERTFLAGS_ISFIXEDLENGTH was specified, and the provider was an OLE DB 1.x provider.

DB_E_BADTYPE

DBCONVERTFLAGS_FROMVARIANT was specified and the type specified in wFromType was not a VARIANT type.

Comments

CanConvert can be called from a command or a rowset. The consumer can call it on a command to inquire about conversions supported by that command and on a rowset to inquire about conversions supported by that rowset. The consumer might be able to call it on a command to inquire about conversions supported on rowsets generated from that command; whether this is supported is specified by the DBPROP_ROWSETCONVERSIONSONCOMMAND property.

Note that converting a value to or from DBTYPE_IUNKNOWN is different than requesting a stream over the value, even though streams are bound using DBTYPE_IUNKNOWN. Providers typically don't support conversion of character or binary values to and from DBTYPE_IUNKOWN, even though they may support binding such objects as streams.

See Also

IAccessor::CreateAccessor