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

Carl McClellan <[email protected]> Wed, 24 Apr 2002 12:58:44 -0400
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <D14D95745752104AA47F7D338026151B1214CD@cltvelc001.velsol.ireadyworld.com>
Huh? Robert, are you referring to consumer template classes? Im using raw
OLE DB. IAccessor interface does not support those methods. Anyways, I could
have multiple accessors and I could supply the same memory buffer
(potentially) to copy the data from the accessor to the buffer. Memory is
client-owned in my example (sorry, I should have made that clear)


-----Original Message-----
From: Robert Sedor [mailto:[email protected]]
Sent: Wednesday, April 24, 2002 11:56 AM
To: [email protected]
Subject: Re: [OLEDB_DEV] 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 <mailto:[email protected]>
To: [email protected] <mailto:[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
 <http://www.velocitorsolutions.com> Velocitor Solutions
704-731-5396(P)
704-527-1234(F)
770-633-7427(M)