这是我的代码:
byte[] imgg = (byte[])(myReader["StudPic"]);
if (imgg == null)
{
pictureBox11.Image = defaultpic;
}
else
{
MemoryStream mstream = new MemoryStream(imgg);
pictureBox11.Image = Image.FromStream(mstream);
}
我收到此错误:无法将system.dbnull类型的对象强制转换为类型system.byte []
数据类型是Blob。但如果它有一个值,它可以正常工作,它会获取图像。
答案 0 :(得分:0)
你可以添加条件来检查天气是否有价值
if(myReader["StudPic"] != System.DBNull.Value))
{
byte[] imgg = (byte[])(myReader["StudPic"]);
pictureBox11.Image = defaultpic;
}