Hi,
This will work with the northwind database. Note the northwind
database has an offset of 78 (see the ms.write line) you might be able to
replace the 78 with 0 depending on how it is saved in the database. Included
a link to sample program.
Dim dr As DataRow = ds.Tables("Categories").Rows(ListBox1.SelectedInde x)
Dim ms As New System.IO.MemoryStream
Dim bm As Bitmap
Dim arData() As Byte = dr.Item("Picture")
ms.Write(arData, 78, arData.Length - 78)
bm = New Bitmap(ms)
PictureBox1.Image = bm
http://www.onteorasoftware.com/downl...windimages.zip
Ken
-----------------------
"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:Ou**************@TK2MSFTNGP12.phx.gbl...
Dean,
Cast the Image field to a ByteArray, create a MemoryStream from the
ByteArray, convert the MemoryStream to a Bitmap and assign the BitMap to the
Image property of the PictureBox.
This will only work if the image is a "raw" picture. If it has an OLE
wrapper around it won't work, so if you are trying to display images from
Access or the Pictures in the Northwind database, this won't work unless you
can figure out how to remove the OLE weapper.
It works fine if the image in the field is a raw image only.
Something like:
<code (VB.NET) >
Me.PictureBox1.Image = New Bitmap(New
System.IO.MemoryStream(DirectCast(Me.DataSet11.Tab les("PersonPicture").Rows(
0)("Picture"), Byte())))
</code>
-Sam Matzen
"Dean Slindee" <sl*****@charter.net> wrote in message
news:10*************@corp.supernews.com...
Does anybody have an actual example of retrieving an Image data type
column from a SQL Server table using a dataset (not a datareader)? I would like
to see the statements that would move the Image returned in the dataset to
a picture box, like:
For Each dr in ds.tables(0).rows
Pic.Image = dr("ImageColumnName") 'not this simple!
Next
Thanks,
Dean Slindee