C#从数据库中加载照片的

从数据库中读取人员照片信息并加载到图片控件的代码

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 { }

 

上一篇:【DataX】Java中集成DataX开发


下一篇:js中通过ajax接口后台返回的文件流如何进行下载?