For some reason I didn't get DataReader to work. But with DataAdapter and DataSet I got images from DB. I used SQL Server but that shouldn't make any difference.
'start query
' Declare a DataSet object
Dim Images As New DataSet()
myAdapter.Fill(Images, "Eyes")
' With DataAdapter you can close connection, with DataReader you have to keep connection open and close it at the end
conn.Close()
' Buffer to hold image data
Dim ByteArr() As Byte
Dim ImageIndex As Integer
Dim i As Integer
ImageIndex = 0 ' Column index of images, set the right value in here
' Loop all rows
For i = 0 To Images.Tables(0).Rows.Count - 1
' Read a BLOB to buffer
ByteArr = CType(Images.Tables(0).Rows.Item(i).Item(ImageIndex), Byte())
' Create a memory stream of the buffer
Dim ImageStream As New MemoryStream(ByteArr)
' Get the image from the memory stream
PictureBox1.Image = Image.FromStream(ImageStream)
' "Refresh" display
Application.DoEvents()
' Wait 3 seconds
System.Threading.Thread.Sleep(3000)
Next i
You also have to import System.IO namespace to use memory stream.
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Offline 1,024 posts
since Aug 2008