By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
* "harish" <an*******@discussions.microsoft.com> scripsit:
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?

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
Binary Datatype
-----Original Message-----
* "harish" <an*******@discussions.microsoft.com> scripsit:
I can't display image from SQL Database to Picture box
Control.
How do you safe the image to the database? Which

datatype did youspecify for the field holding the image?

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #3

P: n/a
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
Binary Datatype

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.