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

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
 
H

Herfried K. Wagner [MVP]

* "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?
 
C

Cor

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top