I'm trying to load a pre-saved images from an SQL Server CE VarBinary column into a PictureBox.
The column content is a bitmap image stored in varbinary format.
MemoryStream ms = new MemoryStream();
byte[] outbyte = new byte[100];
Int32 ordinal = 0;
conn.Open();
SqlCeDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
     ordinal = reader.GetOrdinal("FaceStamp");//FaceStamp: VarBinary column storing Bmp.
     outbyte = (byte[])reader[ordinal];
     ms.Write(outbyte, 0, outbyte.Length);
     ms.Seek(0, SeekOrigin.Begin);
     pictureBox1.Image = Image.FromStream(ms);
}          
conn.Close();
// Code below is the code I used to save the Bitmap image to the database
Bitmap bmi = cam.GetBitmap(); // Capture image from webcam which I've tested working.
ImageConverter converter = new ImageConverter();
byte[] byteArray = new byte[0];
byteArray = (byte[])converter.ConvertTo(bmi, typeof(byte[])); 
insert.Parameters.AddWithValue("@image", byteArray);
insert.ExecuteNonQuery();
I get an error at the following line:
pictureBox1.Image = Image.FromStream(ms);
Saying
{"Parameter is not valid."}
Any tips?
Thank you.
 
     
     
    