Re: Getting BLOB fields

Yuancai Ye <[email protected]> Fri, 10 May 2002 10:46:40 -0700
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
Hi, Michal:
   I saw the char '?' with your SQL statement in your
previous message. So you want to open a corrupted
Access file. Maybe the corrupted access file leads to
this problem.

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:
> Hi,
>
> What do you mean, "parametrized statement"? As far
> as I can see, there's
> only one accessor, it retrieves two fields: ID and
> Data.
> And this works in ALMOST ALL cases. We've never
> encountered this kind of
> problem before.
> What might help is that the guy who sent us this
> database file (ooops,
> made a mistake below: this is MS Access, not SQL
> Server!) had a problem
> with the database, it was corrupted or something (he
> was getting weird
> errors while trying to open the database file in MS
> Access).
>
> Regards
>
>         Michal
>
> > -----Original Message-----
> > From: Yuancai Ye [mailto:[email protected]]
> > Sent: Friday, May 10, 2002 13:35
> > To: [email protected]
> > Subject: Re: [OLEDB_DEV] Getting BLOB fields
> >
> >
> > Hi,
> >    You use a parameterized statement to retrieve a
> > rowset. If so, two accessors are involved at
> least. I
> > usually use OleDBPro instead of ATL consumer
> > templates. If you like, see the samples BLOBs and
> > AOTBLOB inside the OleDBPro module.
> >
> > 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:
> > > Hi,
> > >
> > > This is not the case since we retrieve only one
> > > record at a time. We use
> > > the following command in our accessor: "SELECT
> Data
> > > FROM Session WHERE
> > > (ID=?)". Of course, the accessor also contains a
> > > LONG m_ID field
> > > mapped properly.
> > >
> > > Regards
> > >
> > >         Michal
> > >
> > >
> > > > -----Original Message-----
> > > > From: Yuancai Ye [mailto:[email protected]]
> > > > Sent: Friday, May 10, 2002 13:15
> > > > To: [email protected]
> > > > Subject: Re: [OLEDB_DEV] Getting BLOB fields
> > > >
> > > >
> > > > 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.
> > >
> > > 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.
>
> 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.