无法将类型为“System.DBNull”的对象强制转换为类型“System.Byte[]”。
//publicvoidGet_Image(stringygname,PictureBoxpb)//将图片从数据库中取出//{/*byte[]imagebytes=new...
// public void Get_Image(string ygname, PictureBox pb)//将图片从数据库中取出
//{
/* byte[] imagebytes = new byte [0];
conn.Open();
SqlCommand com = new SqlCommand("select * from tb_Customer where CID='" + ygname + "'", conn);
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
imagebytes = (byte[])dr.GetByte(8);
// imagebytes = (byte[])dr.GetValue(8);
//imagebytes = (byte[])dr.GetValue(11);
}
dr.Close();
conn.Close();
MemoryStream ms = new MemoryStream(imagebytes);
Bitmap bmpt = new Bitmap(ms);
pb.Image = bmpt; 展开
//{
/* byte[] imagebytes = new byte [0];
conn.Open();
SqlCommand com = new SqlCommand("select * from tb_Customer where CID='" + ygname + "'", conn);
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
imagebytes = (byte[])dr.GetByte(8);
// imagebytes = (byte[])dr.GetValue(8);
//imagebytes = (byte[])dr.GetValue(11);
}
dr.Close();
conn.Close();
MemoryStream ms = new MemoryStream(imagebytes);
Bitmap bmpt = new Bitmap(ms);
pb.Image = bmpt; 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询