/// <summary>
/// 将图片从数据库中取出
/// </summary>
/// <param name="ygname">员工编号</param>
/// <param name="pb">PictureBox对象</param>
public void Get_Image(string ygname, PictureBox pb)
{
byte[] imagebytes = null;//声明字节数组变量
conn.Open();//打开数据库连接
SqlCommand com = new SqlCommand(//创建命令对象
"select * from tb_employee where employeeID='" + ygname + "'", conn);
SqlDataReader dr
= com.ExecuteReader();//执行SQl命令
while (dr.Read())//读取数据库中的数据
{
imagebytes
= (byte[])dr.GetValue(11);//得到图象的字节数据
}
dr.Close();
//关闭数据读取器
conn.Close();//关闭数据库连接
MemoryStream ms = new MemoryStream(imagebytes);//创建内存流对象
Bitmap bmpt = new Bitmap(ms);//得到BMP对象
pb.Image = bmpt;//显示图像信息
}