LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve a picture stored in Access

I have an Access database that has .jpg pictures stored in it. I can use the Database Connectivity VI's to select a given picture from the database, but I determined that the datastream I get is not the .jpg picture, but rather an "object package" that somehow contains the picture within it. Does anyone know how I can extract my picture from that datastream?
0 Kudos
Message 1 of 4
(2,380 Views)
Hello,
You are correct! The DB Tools Select Data.vi will typically return a 2D array of the ‘variant’ data type. The variant data type is as you mentioned essentially a container for information. This is because LabVIEW does not know what type of data you are pulling from the database. To extract your picture from the datastream you will need to know how it was saved. You can then use the Database Variant to Data.vi to convert the object stream into your image. I have found some example code on our internal site that may be useful to you. You will notice in the “read jpeg from mdb.vi” that the “type” input to Database Variant to Data is a cluster of constants. These constants correspond to the image data in the “write jpeg to mdb.vi”. This is what allows us to extract the image from the data stream. Best of luck with your application!

Chris J
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,366 Views)
Chris,

Thanks for the reply. You are absolutely correct in that I simply don't know what format that data stream is.

The solution you found is a very workable solution. The only drawback to it, is that it's LabVIEW-specific because you are storing a data stream in "picture" format. It would require me to convert all the pictures stored in my database to this format. But, it is definitely a workable option.

I have been trying to dig in to OLE drag-and-drop functionality more. There must be some way to take the current datastream I get back from Access and send it to some ActiveX object that interprets it as an object package and then allows me to access the contents within. Do you think that sounds promising?

Rob.
0 Kudos
Message 3 of 4
(2,359 Views)
Hello Rob,
I am not aware of an ActiveX object that will automatically interpret data from your database without knowing how it was stored. That does not mean that no such object exists. I simply am not aware of such an object. Perhaps someone else has encountered this issue and can share their solution…

Best Regards
Chris J
National Instruments
0 Kudos
Message 4 of 4
(2,336 Views)