getting parameter is not valid : Trying to retrieve an image
<p>i have spent 2 months trying to insert an image into database and retrieve it again!,i have succeeded to insert the image into database ,but when i try to retrieve it into picturebox i get this exception
btw i'm using scanner so i dun need to browse a file i just want to insert it from picturebox into database and retrieve it again into picturebox</p>

<p>Insert Step</p>

<p>//---------------</p>

<pre><code>MemoryStream ms = new MemoryStream();
PBoxGuestImage.Image.Save(ms, ImageFormat.Jpeg);
Byte[] PicArray = new Byte[ms.Length];
ms.Position = 0;
ms.Read(PicArray, 0, PicArray.Length);

CMD.CommandText = "Insert Into TestTable(TestImage) Values (@ParTestImage)"
CMD.Parameters.AddWithValue("@ParTestImage", PicArray);
//---------------
//this works great


//Retrieve Step

Image NewImage;
byte[] content = (byte[])TestReader["TestImage"];
TestPictureBox.Image = null;
using (MemoryStream stream = new MemoryStream(content, 0, content.Length))
{
 stream.Write(content, 0, content.Length);
 NewImage = Image.FromStream(stream, true); //at this line i get the exception
}
TestPictureBox.Image = NewImage;
</code></pre>

<p>is there anyway to solve this issue ?</p>

<p>Thanks.</p>
