Read and Write Images to Access Ole Object Field

This short snippet demonstrates how to write an image (jpg file) to an Ole Object field in Microsoft Access and then how to retrieve that image and display it in a picture box.

First, create an Access database (I was using Office 2013 but earlier versions should work) and a table with one field called pic. Set the field type of the pic field to Ole Object.

Writing the image to the database

The following code write an image to the pic field.

Once you have executed this statement you can check your database table and you should see that the field contains the text “Long Binary Data”, this is our image.

Reading an image from the Ole Object field

This next piece of code will read Long Binary Data value from the Ole Object field and convert it to a byte array. Once converted, the byte array will then be converted to an Image which we can then use to assign to a picture box or use in any other way we like. For this example, add a PictureBox control to your form and then use the following code to read the image:


Leave a Reply

Your email address will not be published. Required fields are marked *