c# 从数据库中读取图片数据流,然后转换成图片显示到网页上?

byte[] b = Convert.FromBase64String(theAnnotation.Rows[z]["DocumentBody"].ToString()); MemoryStream stream = new MemoryStream(b, 0, b.Length); Bitmap tempimg = new Bitmap(stream); 我想将数据流转换成图片显示到网页上面。最好能放到控件上, 能不能用GridView 控件将查询结果显示出来,数据流自动转换成图片
最新回答
流水浮灯

2024-10-31 10:58:45

yte[]
im
=
(byte[])commond.executescalar();
memorystream
stream
=
new
memorystream(im,
false);
picturebox1.image
=
image.fromstream(stream);
//报错,参数无效????
stream.close();
con.close();
sqlcommand
commond
=
new
sqlcommand("select
personimage
from
temp",
con);
这里需要修改一下,你要判断你要找的是哪个图片?
修改为
using(memorystream
ms=new
memorystrem(im))
{
picturebox1.image
=
image.fromstream(stream);
}