Results 1 to 2 of 2

Thread: Raw Gif/Jpeg And SQL Server

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Q.C., Phils.
    Posts
    27

    Post

    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

  2. #2
    Guest

    Post

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width