Loading Image

  • Hi,

    I have a question.

    When we use the Stream object in ADO to get an image from a SQL Server database, do we absolutly need to save the file on the harddisk temporarely to open it in a PictureBox in Visual Basic ?

    Here's my actual code to load the image :

    Set strStream = New ADODB.Stream

    strStream.Type = adTypeBinary

    strStream.Open

    strStream.Write rs.Fields("ImgImage").Value

    strStream.SaveToFile "C:\Temp.bmp", adSaveCreateOverWrite

    Image1.Picture = LoadPicture("C:\Temp.bmp")

    Kill ("C:\Temp.bmp")

    What if I use other control than a PictureBox ? Like in my reports, what should I do to load the image directly from the database ?

    Thank You,

    DaSaint

    security@army.net

  • As far as I know you have to write to disk then read it back in. I don't the picture control supports the IStream interface. Possibly you could find something 3rd party that does. Have not looked at this in .Net so that might be an option. Not sure how data binding does it - I'd guess basically the same thing, but maybe worth checking.

    Andy

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply