Link to home
Start Free TrialLog in
Avatar of chandua
chandua

asked on

Control to load a JPG file - Binary stream

Hi,

is there any control which can load a jpg file by passing the Binary stream.


pls let me know asap.
thanks.
Avatar of _TAD_
_TAD_



No, but you can load an image object from a stream and then drop that Image onto a picturebox.


it will look something like this:

picturebox1.Image = Image.FromStream(myBinaryStream);
Avatar of chandua

ASKER

hi TAD,

i am creating a Webpart (SPS 2003), i cant have a picture box in it.
Avatar of chandua

ASKER

hi TAD,

i am trying to get the stream from database
string sqlText = "SELECT img_data FROM Image WHERE img_pk = " + ImageId;
SqlConnection connection = new SqlConnection( ConfigurationSettings.AppSettings["DSN"].ToString() );
SqlCommand command = new SqlCommand( sqlText, connection);
 //open the database and get a datareader
connection.Open();
SqlDataReader dr = command.ExecuteReader();
if ( dr.Read()) //found image
{
 pictureBox1.Image=Image.FromStream((byte[]) dr["img_data"]);
}
i cant pass the dr["img_data"].. how do i convert to straeam/
ASKER CERTIFIED SOLUTION
Avatar of _TAD_
_TAD_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial