Re: Getting BLOB fields

Yuancai Ye <[email protected]> Fri, 10 May 2002 10:15:14 -0700
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
Hi,
   Did you release the BLOB object after retrieving a
BLOB before moving to the next record?

Yuancai (Charlie) Ye
See 30 real well-tested advanced OLEDB samples
Use of free SocketPro for creating super client and
server application with numerous samples
www.udaparts.com

--- Michal Blazejczyk
<[email protected]> wrote:
> 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.


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Mother's Day is May 12th!
http://shopping.yahoo.com

You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.