使用vb.net 2005从sql server数据库中恢复映像时出错 [英] There is an error while retriving an image from sql server database using vb.net 2005

查看:104
本文介绍了使用vb.net 2005从sql server数据库中恢复映像时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Label1.Text = DataGridView1.CurrentRow.Cells(0).Value()

Label1.Text = DataGridView1.CurrentRow.Cells(0).Value()

推荐答案

您是否期望Label(基于文本的控件)有一个基于字符串的Text属性,可以接受原始二进制数据到图像而不抱怨吗?



编号

将原始数据转换为字节数组,将其转换为MemoryStream,并使用Image.FromStream为您提供图像。然后,您可以在适当的基于图像的控件中显示(具体取决于您的环境 - 网络将与winforms不同)。
Did you expect a Label (which is a text based control) to have a string based Text property that could accept raw binary data to an image without complaining?

No.
Convert the raw data to an array of bytes, convert that to a MemoryStream, and use Image.FromStream to get you an image. You can then display that in an appropriate image based control (exactly what will depend on your environment - web ones will be different from winforms ones).


这篇关于使用vb.net 2005从sql server数据库中恢复映像时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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