从数据库将图片读取到图片框 [英] reading picture to a Picture box from a database

查看:71
本文介绍了从数据库将图片读取到图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

am试图从数据库的图片字段中读取图片,使其可以显示在图片框中


am trying to read picture from a picture field in a database so that it can appear on the Picture box


Do While dr.Read
    Me.phoneTextBox.Text = dr("Phone")
    Me.emailTextBox.Text = dr("Email")
      
    Me.PictureBox1.Image = dr("Picture")     ' error line
 Loop




在错误行上它告诉我(无法将类型为"System.Byte []"的对象强制转换为类型为"System.Drawing.Image")


请帮助我




on error line it tell me (Unable to cast object of type ''System.Byte[]'' to type ''System.Drawing.Image'')


please help me out

推荐答案

错误表示它的意思.您是否考虑做一些工作,而不是猜测并要求我们为您做您的工作?

字节代表一幅图像,但它们还不是图像.您可以使用字节流(即此数据)构造图像.然后,您可以将该图像分配到图片框.
The error means what it says. Did you consider doing some work instead of guessing and asking us to do your work for you ?

The bytes represent an image, but they are not yet an image. You can construct an image using a stream of bytes, which is what this data is. Then you can assign that Image to your picture box.


这篇关于从数据库将图片读取到图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆