I can't display image from SQL Database to Picture box

  • Thread starter Thread starter harish
  • Start date Start date
H

harish

Hi friends

I am facing problem as follow

I can't display image from SQL Database to Picture box
Control.

Here are the codes that I am writing

Dim arrPicture() As Byte = _
CType(drSql.Item("Picture"), _
Byte())
Dim ms As New MemoryStream(arrPicture)

Try

With pctCategory
.Image = Image.FromStream(ms)
.SizeMode = PictureBoxSizeMode.CenterImage
End With
Catch exArg As ArgumentException
MessageBox.Show(exArg.ToString)
End Try

Following error is coming

"System.ArgumentException: Invalid parameter used.
at System.Drawing.Image.FromStream(Stream stream,
Boolean useEmbeddedColorManagement)
at System.Drawing.Image.FromStream(Stream stream)
at WindowsApplication1.frmCategory.FillData
(SqlDataReader drSql) in C:\HARISH\vb\Project1
\WindowsApplication1\frmCategory.vb:line 264"

I can save the picture to Database.

please reply
 
* "harish said:
I can't display image from SQL Database to Picture box
Control.

How do you safe the image to the database? Which datatype did you
specify for the field holding the image?
 
Hi Harish,

I was also looking long for your problem and the code, I saw nothing wrong.

And Herfried had the right conclusion I thought.

The datatype has to be "image".

I hope this helps a little bit?

Cor
 
Back
Top