Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am trying to read picture from a picture field in a database so that it can appear on the Picture box

Do While dr.Read
    Me.phoneTextBox.Text = dr("Phone")
    Me.emailTextBox.Text = dr("Email")
    Me.PictureBox1.Image = dr("Picture")     ' error line

on error line it tell me (Unable to cast object of type 'System.Byte[]' to type 'System.Drawing.Image')

please help me out
Updated 6-Aug-11 19:02pm

1 solution

The error means what it says. Did you consider doing some work instead of guessing and asking us to do your work for you ?

The bytes represent an image, but they are not yet an image. You can construct an image using a stream of bytes, which is what this data is. Then you can assign that Image to your picture box.
Share this answer
kabiru ajibosin 6-Aug-11 19:13pm    
i dnt knw hw to use streams. please give me a sample code related to the one above so i can read the file. please
Christian Graus 7-Aug-11 0:15am    
Did you consider trying google ? Or buying a book ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900