Thread: IMAGE Data type
View Single Post
  #3 (permalink)  
Old June 2nd, 2004, 05:42 AM
ranakdinesh ranakdinesh is offline
Authorized User
 
Join Date: Apr 2004
Location: Gurgaon, Haryana, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ranakdinesh
Default

what is the error in this code whenever i i run the code i recieve an error at Bitmap bmp = new Bitmap(stream);
as addtional inforamtion



string strcmd = string.Format("select photo from employee where employeeid = '1199'");
SqlCommand cmd =new SqlCommand(strcmd,conn);
byte[] b = (byte[])cmd.ExecuteScalar();
    if(b.Length > 0)
{

System.IO.MemoryStream stream = new System.IO.MemoryStream(b, true); stream.Write(b, 0, b.Length);

        Bitmap bmp = new Bitmap(stream);


                //if(bmp.Width>500 && bmp.Height >300)
                {
                // Bitmap bmp1 = new Bitmap(bmp,new Size(500,300));
                // photo.Image = bmp1;
                }
                //else
                {
                // photo.Image = bmp;
                }



            }
        conn.Close();
        }

dinesh Rana