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

Robert Sedor <[email protected]> Wed, 24 Apr 2002 11:55:53 -0400
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
How do I get data from buffer after call to IRowset GetData?Your Accessor is your buffer.

ex.
pRowset->GetData( hRow, pAccessor->GetHAccessor(nAccessor), pAccessor->GetBuffer( ) );

Robert Sedor
Pitney Bowes, Inc.

  ----- Original Message ----- 
  From: Carl McClellan 
  To: [email protected] 
  Sent: Wednesday, April 24, 2002 11:23 AM
  Subject: [OLEDB_DEV] How do I get data from buffer after call to IRowset GetData?


  Hi everybody, 

  I have a couple of questions about getting data out of a buffer after calling IRowset GetData. 
  I have allocated a BYTE array with the appropriate number of bytes based on the max row size....       

  BYTE* pBuffer = (BYTE*)malloc(dwOffset); 

  After the call to GetData I am ready to get the data for each column...            

  hr = pIRowset->GetData(rghRows[0],hAccessor,pBuffer); 

  for (ULONG ulCurrentCol = 0; ulCurrentCol < lNumCols; ulCurrentCol++) 
  { 

          .... Get column data 

  } 




  The problem I am having is accessing certain types of data from the buffer. 
  If pBindings is my array of DBBINDING structures, then I access the data THUSLY 

  pBuffer[pBindings[ulCurrentCol].obValue] 



  Now, I assume that obValue is a 32 bit value that holds a pointer to the real data so in 
  Order to access the data, I need to dereference the pointer and cast the BYTE away to whatever.... 

  LONG *pLongValue = reinterpret_cast<LONG*>(&pBuffer[pBindings[ulCurrentCol].obValue]); 

  DOUBLE *pDoubleValue = reinterpret_cast<DOUBLE*>(&pBuffer[pBindings[ulCurrentCol].obValue]); 

  LPWSTR pwszString = (LPWSTR)&pBuffer[pBindings[ulCurrentCol].obValue]; 

  And so on and so forth.... 



  The problem is that I can never seem to get any meaningfull  data out of  columns that return 
  Doubles, currency, or dbtimestamp values. Having said that, I know that the status is DBSTATUS_S_OK 
  (because I am binding VALUE | LENGTH | STATUS when I bind the columns). 



  The platform I am using is SQL Server CE (this is a program I am writing on a Pocket PC device). 



  I would LOVE to see some sample code that somebody has written that extracts data and tests the status 
  Of any coulumn/type. 

  I hope this was clear.... 

  Carl McClellan 
  Software Engineer 
  Velocitor Solutions 
  704-731-5396(P) 
  704-527-1234(F) 
  770-633-7427(M)