i have stored jpeg images in database table. now i want to retrieve them. here is the code
MemoryStream stream = new MemoryStream();
try
{
cnn.Open();
cmd = new
SqlCommand("select pics from images", cnn);
byte[] image = (byte[])cmd.ExecuteScalar();
stream.Write(image, 0, image.Length);
Bitmap bitmap = new Bitmap(stream);
Response.ContentType = "image/gif";
bitmap.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Bmp);
}
finally
{
cnn.Close();
stream.Close();
}
but when i run the application it gives me the following error
Parameter is not valid.
Bitmap bitmap = new Bitmap(stream);
can somebody tells me what i need to correct.