Discussion Locked

Picture from Access 2k table to VB form

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Picture from Access table to VB form
I have an Access 2000 table column set to the OLE Object datatype in which I am storing jpeg images. I am attempting to display said images on a vb form. When I retrieve a record from my access database I storethe record in a variant-type array. The elements of the array are exposed through property procedures that my form uses to access the data, which is then assigned to the form's controls. When I attempt to assign the property containing the image to the picture property of a picture box control, I get a type mismatch error. How exactly do I display a picture on a form using ado rather than the loadpicture method or referring to the picture property of another control?

5 replies

by sl-campbell

You may need to use an OLE Container control and set its' data source to the recordset object and data field to the field to be used, as the value returned from the rs is a dbLongBinary. It is then the application that was used to fill the field with the data that the OLE container calls to re-display that data in the way and format that it was stored by the application - this is not necessarily the same format that you would expect, (that is to say: "it's a picture that was put into the field- even if it was via a certain application - so the field must return a picture" - is not correct).

by sl-campbell

(I hit the wrong keys)

The long binary field that contains picture data would also contain other info that is not picture data. A picture box needs picture data.

by afisher

I decided to store my images on a network directory and store the image file names in my table. My application middle tier stores the path to this folder. When displaying a picture, I concatenate the path and the file name to supply to the loadpicture function. When saving a new record, users are able to navigate the network in search of pictures. I use the copyfile api to ensure that the pictures they choose are copied to the directory mentioned above. I am not sure how to check for duplicate file names when performing this sort of operation, so I may post a question on this if I can't uncover a solution on my own. I considered using the GetChunk function and storing the images as BLOBs, but I didn't want to bog down my database. Thanks for your help!

by afisher

Considering the bFailIfExists argument, I probably won't post a question about handling duplicate file names!

This discussion is closed to new replies.