无法使用c#中的sql server数据库从数据库中检索图像

问题描述:

我使用以下代码从数据库中检索图像,



I used following code for retrieving the image from database,

byte[] img_arr1 = (byte[])dr["photo"];
MemoryStream ms1 = new MemoryStream(img_arr1);
ms1.Seek(0, SeekOrigin.Begin);
pictureBox1.Image = Image.FromStream(ms1);





但我在最后一行得到例外,





but i got exception in last line which is,

pictureBox1.Image = Image.FromStream(ms1);



参数无效。

用于存储图像我使用的图像数据类型。

请帮忙。

谢谢。


"Parameter is not valid."
For storing image i used image datatype.
Please help.
Thank you.

这不是检索... 为什么我得到参数无效。我从数据库中读取图像时出现异常? [ ^ ]
It's not the retrieval... Why do I get a "Parameter is not valid." exception when I read an image from my database?[^]


remove

ms1.Seek(0, SeekOrigin.Begin);

此行并尝试。
remove
ms1.Seek(0, SeekOrigin.Begin);
this line and try.