Re: How do I get data from buffer after call to IRows et GetData?

Robert Sedor <[email protected]> Wed, 24 Apr 2002 19:18:52 -0400
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
MessageIf you are looking for a way to do data conversions, then you might want to look into the OLE-DB Core Components.

OLE-DB Data Conversion Library  MSDADC.DLL
OLE-DB Root Enumerator Object MSDAENUM.DLL
OLE-DB Error Object                  MSDAER.DLL


Use the IDataConvert Interface.  Although you are only working with the CURRENCY data type,  when it comes to other data types
like NUMERIC it becomes more problematic.

// Convert the DBNUMERIC data type
 CComPtr<IDataConvert>  pIcvt;
 
 ULONG  cbDstLength = NULL;
 double dblValue    = 0.00;

 hr = pIcvt.CoCreateInstance( CLSID_OLEDB_CONVERSIONLIBRARY, 
                        NULL,
         CLSCTX_INPROC_SERVER );
 if ( FAILED( hr ) ) 
  return AtlReportError( CLSID_TimeZone, CComBSTR( L"Data Conversion Utility Unavailable" ), IID_ITimeZone, hr );
 
 hr = pIcvt->DataConvert( DBTYPE_NUMERIC,DBTYPE_R8, // src, dest types
                             (ULONG) sizeof(struct  tagDB_NUMERIC),
        &cbDstLength,
        (void *) &getTimeZone.m_GMTHrsOff,
        &dblValue,
        (ULONG) sizeof (double),  
        DBSTATUS_S_OK,
        0,
        getTimeZone.m_GMTHrsOff.precision,
        getTimeZone.m_GMTHrsOff.scale,
        DBDATACONVERT_DEFAULT );
 if ( FAILED( hr ) )
  hr = S_OK;

  ----- Original Message ----- 
  From: Carl McClellan 
  To: [email protected] 
  Sent: Wednesday, April 24, 2002 6:26 PM
  Subject: Re: [OLEDB_DEV] How do I get data from buffer after call to IRows et GetData?


  Well, I kinda figured out a way to do it but I dont really like it.

  I figured out that money types in SQL Server correspond to DBTYPE_CY which really use an eight byte (UI8) representation. I used the C++ datatype CURRENCY to extract the data out and called VarR8FromCy to convert the CURRENCY type to double. This seems to work nicely. What I really wanted to do was to set up my DBBINDING struct to 'tell' the service provider to do the conversion for me. That is, once I get the columninfo, I would set the wType (in my bindings) to DBTYPE_R8 whenever I got a column with a type of DBTYPE_CY. Of course, there is no conversion for this on the provider side, as there is only a (safe) conversion to DBTYPE_I8 ...duh!

  Why do I have to do all the work? , lol - I know that there must be a way to specify the conversion (other than specifying a 50 char string or something)....

  But since I am short on time - I am going to convert myself with VarR8FromCy.....