Partager via


IConvertType::CanConvert

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

Syntax

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 IConvertType::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

    IConvertType::CanConvert is to determine whether the conversion is supported when setting, getting, finding, filtering, or seeking on columns of the rowset or row. This flag is mutually exclusive with DBCONVERTFLAGS_PARAMETER.

    DBCONVERTFLAGS_ISFIXEDLENGTH

    IConvertType::CanConvert is to determine whether 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 supported only by OLE DB version 2.0 or later providers.

    DBCONVERTFLAGS_ISLONG

    IConvertType::CanConvert is to determine whether the long version of the DBTYPE specified in the dwFromType can be converted to the DBTYPE specified in wToType. This flag is valid only when used in conjunction with a variable-length DBTYPE. This flag can coexist with either DBCONVERTFLAGS_COLUMN or DBCONVERTFLAGS_PARAMETER. This flag is supported only by OLE DB version 2.0 or later providers.

    DBCONVERTFLAGS_PARAMETER

    IConvertType::CanConvert is to determine whether the conversion is supported on the parameters of the command.

    DBCONVERTFLAGS_FROMVARIANT

    The DBTYPE specified in the wFromType represents a type within a VARIANT. IConvertType::CanConvert returns whether the conversion from a VARIANT of that type to the type specified in wToType is allowed. For providers that support PROPVARIANT, this applies to conversions from PROPVARIANT as well.

Return Code

  • S_OK
    The requested conversion is available.

  • S_FALSE
    The requested conversion is not available.

    wFromType or wToType was not a valid type for the provider, and the provider was a version 2.0 or later 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 IConvertType::CanConvert was called on a rowset or row.

    The DBCONVERTFLAGS_PARAMETER bit was set, and IConvertType::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.

    DBCONVERTFLAGS_COLUMN and DBCONVERTFLAGS_PARAMETER were both specified. (These two flags are mutually exclusive.)

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

Comments

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

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_IUNKNOWN, even though they may support binding such objects as streams.

See Also

Reference

IAccessor::CreateAccessor