Load Picture From SQL Database Table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Table containing an Image datatype Column. On a Windows Form I have a listbox containing the titles of image files e.g. sample.jpg, populated from the same table When the user clicks on a list item I want the related image to be displayed in a PictureBox contol. I have tried ExecuteScalar() to retieve the image via a SQL Command, using the Picture Title as a Parameter but it returns nothing. Could anyone please tell me the best way of doing this?
 
Hi Geoff,

These links might help you:
HOW TO: Copy a Picture from a Database Directly to a PictureBox Control with
Visual C#
http://support.microsoft.com/default.aspx?scid=kb;en-us;317701&Product=vcSnet

HOW TO: Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;309158&Product=vcSnet

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Geoff Murley said:
I have a Table containing an Image datatype Column. On a Windows Form I
have a listbox containing the titles of image files e.g. sample.jpg,
populated from the same table When the user clicks on a list item I want
the related image to be displayed in a PictureBox contol. I have tried
ExecuteScalar() to retieve the image via a SQL Command, using the Picture
Title as a Parameter but it returns nothing. Could anyone please tell me
the best way of doing this?
 
In VB

This is it from a dataset
Dim abyt() as byte = CType(ds.Tables(0).Rows(0)(0), Byte())
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)

However not for an ole embeded object image from an access database.

Cor
 
Back
Top