locked
Display image from the table RRS feed

  • Question

  •  

    Hai,

     

    If i have image in a database table , how can i display this image.

     

    I can able to store the image in the database but how to retrieve it. I am using VB 2005 with SQL Server 2005.

     

    Can it possible to display in microsoft paint or image viewer or else any another image compatible software.

     

    Hope you reply soon.

     

    Thanks.

     

     

    Regards

    Kashif Chotu

    Wednesday, December 26, 2007 3:12 PM

Answers

  •  

    Images stored in a database(in your case SQL server ) is stored as a Byte Array

    so to display in VB use this

     

    Dim arrPicture as Byte()

    Dim Img As Image

    If arrPicture.Length > 0 Then

    Dim msStream As New System.IO.MemoryStream(arrPicture)

    Img = New System.Drawing.Bitmap(System.Drawing.Image.FromStream(msStream))

    Else

    Img = nothing

    End if

    Wednesday, December 26, 2007 5:08 PM

All replies

  •  

    Images stored in a database(in your case SQL server ) is stored as a Byte Array

    so to display in VB use this

     

    Dim arrPicture as Byte()

    Dim Img As Image

    If arrPicture.Length > 0 Then

    Dim msStream As New System.IO.MemoryStream(arrPicture)

    Img = New System.Drawing.Bitmap(System.Drawing.Image.FromStream(msStream))

    Else

    Img = nothing

    End if

    Wednesday, December 26, 2007 5:08 PM
  • Then use the Image object and display in a Picture Box control

     

    Wednesday, December 26, 2007 6:21 PM