PDA

Click to See Complete Forum and Search --> : Raw Gif/Jpeg And SQL Server


Eclipse DevSoft
Feb 1st, 2000, 10:24 AM
I tried using all the codes that I can find on MSDN regarding displaying an image stored on the database but the images doesn't show properly. It seems you need to store the images as RAW, which means no header. Does somebody know how to retrieve the picure data part or the position of the byte where the picture data begins? Or does someboby have a better idea on how to display the images (either GIF or JPEG) Im Using this code:

oCnn = Server.CreateObject("ADODB.Connection")
oCnn.OPen "DNS=LocalServer;UID=SA;PWD=;Database=MyData"
sSQL = "SELECT ImgType, Photo FROM InvTable WHERE SKU = '123456'"
oRS = oCnn.Execute(sSQL)

PicType = ImgType
PicSize = rs("Photo").ActualSIze
Pic = rs("Photo").GetChunk(PicSize)

Response.ContentType = "image/" & PicType
Response.BinaryWrite Pic
Response.End


see, The PicType will either be "GIF" or "JPEG", I know I stored the image properly because when I dump it to a file, it displays properly on IE or other Image processing tools.

If you have a better code or idea, please help. Thank you very much.

------------------
Share your knowledge, it is the best way to achieve immortality

Feb 3rd, 2000, 12:02 AM
I'm not sure i this will help. What i'm doing is saving the files to disk with just the paths to to the images databased. this way i can save disk space using tif formats. there are a lot of image conversion dll's out there that are very fast.you can convert the images to any image format you want on the way to your web page. Also (if you have an extremly large database)you wont have to worry about your sql timing out when you need to return large arrays of images and your server is getting slammed.