Displaying an image from an MSSQL table.

  • Thread starter Thread starter Wade Wegner
  • Start date Start date
W

Wade Wegner

Hello,

Per the suggestions of the private SQLSERVER group, I have decided to store
images in our database, utilizing the data type Image (MSSQL 2000 Standard
Edition on Windows NT 5.0, Build 2195: Service Pack 4). This solution works
extremely well, and it is very easy to extract these images in a Crystal
Report and display them.

The only problem I have is displaying these images in Access. Currently, I
have an Access 2002 .adp file that I use as a front end to the MSSQL
database. I have a very simple form which consists of a listbox that
displays the names of the images stored in the images table. I want to
allow the users to select one of the image names in the listbox, and have
the image load into an image object that is also in this form. I have not
been able to get this to work!

So, here's my question -- how can I display an image, stored in an MSSQL
column of data type Image, in an image object (or any object!) within Access
2002? I have been unable to find any discussion of this anywhere.

Thanks for your help!

Wade
 
This is possible using the native Access Image Control by extracting the data to a temporary file then
displaying it. MSDN contains examples to do the extracting - search for ReadBlob/WriteBLOB, which use
GetChunk/AppendChunk to access the data.

The relevant office graphics filters must be installed, and there are some caveats and workarounds that
may be required, for example to suppress the 'Loading' dialog, and to prevent crashes when scrolling too
fast through records.

Larry Linsons' imaging samples contain a full illustration of this approach, and additional info on using
the Access Image Control is available on ‘The Access Web’ (see the links page via our sig below for both).

If a commercial alternative may be suitable then our 'DBPix' image control can bind directly to such data,
without the need for any code or temporary files (provided the image data is a suitable format). Asynchronous/background
decoding prevents your app from blocking while images are loaded & decoded, and if you use DBPix to store
the images you can automatically resample them (to normalize the dimensions or create thumbnails), and
use features like lossless JPEG rotation.
 
Back
Top