Freigeben über


IDataConvert::GetConversionSize

Calculates the size of the buffer needed by the destination data type to support a conversion.

Syntax

HRESULT GetConversionSize (
   DBTYPE       wSrcType,
   DBTYPE       wDstType,
   DBLENGTH *   pcbSrcLength,
   DBLENGTH *   pcbDstLength,
   void *       pSrc);

Parameters

  • wSrcType
    [in] The source type of the data.

  • wDstType
    [in] The destination type of the data.

  • pcbSrcLength
    [in] A pointer to the length of the source data, in bytes. This value can be a null pointer.

  • pcbDstLength
    [out] A pointer to memory in which to return the size of the destination buffer required for the conversion, in bytes.

  • pSrc
    [in] A pointer to the source data.

Return Code

  • S_OK
    The method succeeded.

  • E_FAIL
    A provider-specific error occurred.

  • E_INVALIDARG
    pcbDstLength was a null pointer, or the information supplied by the consumer was insufficient to determine the appropriate buffer size.

    pcbSrcLength was a null pointer, and the conversion size was requested for a conversion from a variable-length data type to DBTYPE_STR, DBTYPE_WSTR, DBTYPE_BSTR, or DBTYPE_VARIANT.

  • DB_E_UNSUPPORTEDCONVERSION
    The requested conversion was not supported.

Comments

The size of a fixed-width destination type can be discovered by passing a null pointer in the pSrc parameter. For example, the width of wType can be determined by adding the following code:

pConvert->GetConversionSize(wType, wType, 0, &ulWidth, 0);