Getting BLOB fields
Michal Blazejczyk <[email protected]> Fri, 10 May 2002 12:59:46 -0400
| Newsgroups | gmane.comp.windows.devel.oledb.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello everyone,
We have a problem with our database-access code that uses ATL.
We have a BLOB field in a SQL Server database. We access it using a
specialized accessor class.
Later on the code look like this:
CCommand<CAccessor<COurBLOBAccessor> > BLOBTab;
BLOBTab.ClearRecord(); // set all fields to 0
BLOBTab.Open(Session);
BLOBTab.MoveFirst();
// use BLOBTab.m_Data to get the BLOB data
The session object is valid, the accessor gets bound properly, Open and
MoveFirst return S_OK. In a normal case, the call to MoveFirst (more
specifically, a call to IRowset::GetData) sets BLOBTab.m_Data to a valid
ISequentialStream object.
However, in one case BLOBTab.m_Data isn't set in IRowset::GetData and is
left NULL. Both IRowset::GetData and MoveFirst return S_OK but
retrieving the data is impossible.
What can be the problem?
Michal Blazejczyk
This is how the accessor class looks like:
class COurBLOBAccessor
{
public:
ISequentialStream* m_Data;
ULONG m_Data_Length;
ULONG m_Data_Status;
BEGIN_COLUMN_MAP(CSISessionBLOBAccessor)
BLOB_ENTRY_LENGTH_STATUS(1, IID_ISequentialStream, STGM_READ,
m_Data, m_Data_Length, m_Data_Status)
// BLOB_ENTRY_LENGTH_STATUS is our own macro.
// It seems to be working fine.
END_COLUMN_MAP()
// .... Other stuff
};
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.