从数据库中读取人员照片信息并加载到图片控件的代码
string conn = "Server=192.168.xx.xx;Database=dbName;User ID=sa;password=pwd"; string strSQL = "select top 1 id,picture from tbName"; System.Drawing.Image image = null; try { System.Data.SqlClient.SqlDataReader reader = WEISHENG.COMM.Db.SqlHelper.ExecuteReader(conn, CommandType.Text, strSQL); reader.Read(); if (reader.HasRows) { System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])reader["picture"]); image = System.Drawing.Image.FromStream(ms, true); } else { image = Properties.Resources.defaultPhoto; } this.pictureBox1.Image = image; } catch { }