这是说明对象为空了,就不能强转了,返回值是null,所以不能进行转换操作
比如
byte[])reader["zp"]为空
只要加层判断即可
if (reader["zp"] != DBNull.Value)
{
MemoryStream ms = new MemoryStream((byte[])reader["zp"]);
Image imageBlob = Image.FromStream(ms, true);
pictureBox1.Image = imageBlob;
}
else
{
pictureBox1.ImageLocation = "";
}
黑色头发:http://heisetoufa.iteye.com