1个回答
展开全部
查询image字段的内容和reader的内容就不写了.估计你也会写. 读出image内容: SqlDataReader reader = cmd.ExecuteReader(); byte[] bImg=(byte[])reader["Image字段"]; 然后用下面的代码转换一下即可 //从byte[]中得到图片Image public static Image GetImage(byte[] bData) { try { using (Stream fStream = new MemoryStream(bData.Length)) { BinaryWriter bWriter = new BinaryWriter(fStream); bWriter.Write((byte[])bData); bWriter.Flush(); System.Drawing.Bitmap bitMap = new System.Drawing.Bitmap(fStream); bWriter.Close(); fStream.Close(); Image iImage = System.Drawing.Image.FromHbitmap(bitMap.GetHbitmap()); return iImage; } } catch (System.IO.IOException e) { throw new Exception(e.Message + "Read image data error!"); } } 得到的内容是一个Image 只需要将Image赋值给picturebox就可以了 Image iImage = GetImage(bImg); picturebox.Image = iImage;
记得采纳啊
记得采纳啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询