Access Image Workaround Needed (1 Viewer)

MLUCKHAM

Registered User.
Local time
Today, 01:42
Joined
Jul 23, 2013
Messages
89
Hi

I have a pretty technical problem. I have some images stored in a SQL Table which is linked into Access. These images have to be stored in the database as I also reference them on other platforms (Android, Web etc).

In my Access programme I need to display a continuous form / report showing each image. Now, good old Access cannot display multiple images stored in the database on a continuous form. It can only do this if it is referencing the path to the image.

When the user views the form they will only see about 12 images at a time. I thought of a workaround which is to write the database images back to file to a local temp directory when the user loads the form. The user would be happy to wait for say 10 to 15 seconds whilst the form loads.

However, I cannot find an efficient algorithm to write the images back to a file. The one I am using is a BinarytoString algorithm by motobit which is fine for very small images, but anything over 100kb (which is still pretty small) it goes sooooo slow.

Is anyone else got any ideas as to how to quickly write an image stored as a long binary in an Access DB back to a file? Or do I need to crack open my Visual Studio and write some C# DLL to use instead...? Any advice would be great....:banghead:
 

MLUCKHAM

Registered User.
Local time
Today, 01:42
Joined
Jul 23, 2013
Messages
89
OK - I have fixed this. In the end I created a .Net C# DLL. I built with register for Com Interop. I used the following code: -

Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace CareControlSystems
{
    public class ImageWriter
    {
            public string SaveImageToFile(string SavePath , byte[] bytearray)
            {
                System.IO.File.WriteAllBytes(SavePath, bytearray);
                return SavePath;
            }
    }
}

That was it! I then referenced the DLL in my Access Project and called it like this: -

Code:
Dim ExtImgWriter As New CareControlSystems.ImageWriter
ExtImgWriter.SaveImageToFile(ImgPath, rs.Fields("MealImage").Value)

I can write 23 images totalling about 1.8mb in less than a second. The previous Access only code would take minutes!

So, if you need to display database stored images on a continuous form this is a good work around. :cool:
 

Users who are viewing this thread

Top Bottom