我无法从数据库中检索图像
byte[] image = (byte[])(reader["Can_Pic"]);
if (image == null)
{
Picture.Image = null;
}
else
{
Memory Stream stream = new Memory Stream(image);
Picture.Image = System.Drawing.Image.From Stream(stream);
}
答案 0 :(得分:0)
您的代码应该是这样的:-)
Byte[] image=(Byte[])(reader["Can_Pic"]);
if (image.Length == 0)
{
Picture.Image = null;
}
else
{
MemoryStream stream = new MemoryStream();
stream.Write(image, 0, image.Length);
Picture.Image = new Bitmap(stream);
}