Retrieving OLEObject (Image) from MDB using ADO

Retrieving OLEObject (Image) from MDB using ADO

Post by Paul William » Wed, 15 Dec 1999 04:00:00



Hi,

I am having some problems converting an existing application that uses
DAO to use ADO. The issue is as follows:

Each row of a table in the MDB contains an image of a product as an
embedded object. I need to be able to display this image in a control on
my VB form. The current application does this using DAO, which seems to
provide the OLE Object as a STDPicture that the PictureBox can use.
(i.e. Picture1.picture = rsData!Picture). However, when using ADO this
method does not work as the OLE Object is of the datatype
adLongVarBinary, so the PictureBox does not recognise it as an image. I
have tried binding the PictureBox to the recordset (see below), but this
gives an error. (Error 545 - Unable to bind to field or datamember:
'ProductImage"). The binding does work for all the other columns though
(as they are not images) so I presume the recordset is OK.

<Binding code>
      Set picPrizmIcon.DataSource = MyRecordset
      picPrizmIcon.DataField = "ProductImage"  <= This line gives the
error
</Binding code>

I have not yet attempted saving the OLE Object to file and loading using
LoadPicture(), but this is a bit messy!

Any help appreciated

Best regards,

Paul


 
 
 

Retrieving OLEObject (Image) from MDB using ADO

Post by Robert Smit » Wed, 15 Dec 1999 04:00:00


You have to use GetChunk to pull out the BLOBs to temp files, then you can
use loadpicture to fill your targets.

For good DAO code (and extra tricks you might like after you use the ADO or
DAO Chunking) see: http://www.smithvoice.com/appendin.htm

And, for ADO get the Wrox Press book ADO2.1 Programmer's Reference, it shows
Chunking explicitly in ADO ... BTW if you're doing ADO then this is THE
must-have book. (www.wrox.com)

Robert Smith
Kirkland WA


>Hi,

>I am having some problems converting an existing application that uses
>DAO to use ADO. The issue is as follows:

>Each row of a table in the MDB contains an image of a product as an
>embedded object. I need to be able to display this image in a control on
>my VB form. The current application does this using DAO, which seems to
>provide the OLE Object as a STDPicture that the PictureBox can use.
>(i.e. Picture1.picture = rsData!Picture). However, when using ADO this
>method does not work as the OLE Object is of the datatype
>adLongVarBinary, so the PictureBox does not recognise it as an image. I
>have tried binding the PictureBox to the recordset (see below), but this
>gives an error. (Error 545 - Unable to bind to field or datamember:
>'ProductImage"). The binding does work for all the other columns though
>(as they are not images) so I presume the recordset is OK.

><Binding code>
>      Set picPrizmIcon.DataSource = MyRecordset
>      picPrizmIcon.DataField = "ProductImage"  <= This line gives the
>error
></Binding code>

>I have not yet attempted saving the OLE Object to file and loading using
>LoadPicture(), but this is a bit messy!

>Any help appreciated

>Best regards,

>Paul




 
 
 

Retrieving OLEObject (Image) from MDB using ADO

Post by Paul William » Thu, 16 Dec 1999 04:00:00


Thanks for you help, I had seen some articles about that on MSDN, they were
more for use with asp/SQL Server. I will check out the sites you mentioned.

I hoped there would be a more direct method to restore the object. It would
seem strange that using Jet you could read the object directly. Does anyone
know why this would have changed in ADO. Thinner more generic wrapper or
such like?

Do you think there might be a way to convert to to an Win32 bitmap and
bitblit it via API? Any takers? More one for the winapi newsgroup I suppose.

Another thought, the MDB was created via JET in Access97. I presume this
would not inhibit ADO's ability to read the OLEObject field correctly?

Paul Williams


> You have to use GetChunk to pull out the BLOBs to temp files, then you can
> use loadpicture to fill your targets.

> For good DAO code (and extra tricks you might like after you use the ADO
or
> DAO Chunking) see: http://www.smithvoice.com/appendin.htm

> And, for ADO get the Wrox Press book ADO2.1 Programmer's Reference, it
shows
> Chunking explicitly in ADO ... BTW if you're doing ADO then this is THE
> must-have book. (www.wrox.com)

> Robert Smith
> Kirkland WA


> >Hi,

> >I am having some problems converting an existing application that uses
> >DAO to use ADO. The issue is as follows:

> >Each row of a table in the MDB contains an image of a product as an
> >embedded object. I need to be able to display this image in a control on
> >my VB form. The current application does this using DAO, which seems to
> >provide the OLE Object as a STDPicture that the PictureBox can use.
> >(i.e. Picture1.picture = rsData!Picture). However, when using ADO this
> >method does not work as the OLE Object is of the datatype
> >adLongVarBinary, so the PictureBox does not recognise it as an image. I
> >have tried binding the PictureBox to the recordset (see below), but this
> >gives an error. (Error 545 - Unable to bind to field or datamember:
> >'ProductImage"). The binding does work for all the other columns though
> >(as they are not images) so I presume the recordset is OK.

> ><Binding code>
> >      Set picPrizmIcon.DataSource = MyRecordset
> >      picPrizmIcon.DataField = "ProductImage"  <= This line gives the
> >error
> ></Binding code>

> >I have not yet attempted saving the OLE Object to file and loading using
> >LoadPicture(), but this is a bit messy!

> >Any help appreciated

> >Best regards,

> >Paul



 
 
 

1. How to store / retrieve images in Access MDB ??

Hi all,

Sorry if this question has already been asked before... I am working on a
picture database system. Up to now I have made individual thumbnail files of
all the pictures in my system. This works fine, but I wonder if it would be
possible (and a good idea) to store these thumbnails IN the database, instead
of just a path reference to them.

1) What field type would I have to use to store my thumbnails in the database?
2) How would the actual storage work? Simply by the traditional sequence:
   mytable.addnew
   mytable.fields("thumb") = "c:\thumbnails\thumb1.jpg"
   mytable.update  
   Could it be that simple??
3) And the retrieval? Would it again be as simple as:
    picturebox.picture = mytable.fields("thumb") ??

Hope someone can help me out. As I said, the system with each thumbnail in a
separate file works fine (at least with something like 10,000 pictures), but
I'm afraid, once the numbers grow, I might end up in some kind of trouble. On
the other hand, if I would store the actual thumbnails in the database itself,

this might also lead to a very huge filesize. If something would go wrong with

that file (the database), the trouble would be overwhelming. So, my fourth
question:

4) Would you, dear reader, advise me to store my thumbnails in the database,
or would you rather keep them separate?

Thanks!

Ludo Meyvis
Belgium

2. Many to Many relationships?

3. Retrieving data from Exchange 2000 server using ado/ado.net

4. Problem with SQL7 and IIS

5. Problem using VB to retrieve ASP/XML using ADO recordset

6. Multi-Table PostRecord Problem

7. images storing/retrieving in sql7 server how i do that combining with VB(ado)

8. Dynamic SQL ERRORS

9. Storing and viewing images in .mdb database using Vb5

10. Huge MDB using OLE images?

11. Retrieving images from SQL Server using ColdFusion

12. Retrieving output parameters AND updating image/text column from single stored procedure using DBLibrary