This shows how to read image from Microsoft SQL server database. It streams a bitmap image and saves as jpeg image file.
In order to improve the performance, I save the image in a directory where ASP.NET stores temporary files. If the request image exists in cache, it doesn't need to touch database and returns the existed image.

I create a generic handler called "GetProductImage.ashx". How to use it? For example in C#