如何从数据库中检索图像并在图像控制中显示图像 [英] how to retrive image from database and display image in image control

查看:89
本文介绍了如何从数据库中检索图像并在图像控制中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从数据库中检索图像并在图像控制中显示图像。

我希望图像控件中的显示图像类似于facebook dp。



存储图像的图像数据类型

how to retrive image from database and display image in image control.
i want display image in image control similar to facebook dp.

stored image in image datatype

推荐答案





我认为在数据库中存储图像不是更好的方法。



所以将图像存储在本地文件夹中然后将imagepath保存在数据库表中



当你想要那张图片只是将那条路径放在图像控制中时



Hi,

I think storing images in database is not preferable method.

so store image in local folders then save imagepath in database table

when ever you want that image just place that path in image control

 //dt contains retrieved data from database
image1.ImageUrl=dt.rows[0]["imagepath"].tostring();





所有最好的



All the Best


好吧,我使用的一种方式是我将图像的路径存储在数据库中,然后在我的应用程序代码中读取该路径并在图像框中渲染图像。



System.Drawing.Image和Bitmap课程是你的朋友操纵图像并显示如下:



well, the one way i use is i store the path of the image in the database and then read that path in my application code and render the image in the image box.

System.Drawing.Image and Bitmap classes are your friends to manipulate the image and display it like so:

System.Drawing.Image img = (System.Drawing.Image)new Bitmap(filepath);





文件路径是路径您将从数据库中读取。



希望这有助于...

干杯。



the filepath is the path that you would read from the database.

Hope this helps...
Cheers.


http://csharpdotnetfreak.blogspot.com/2009/07/display-images -gridview-from-database.html [ ^ ]



从这里引用此示例源代码...:)
http://csharpdotnetfreak.blogspot.com/2009/07/display-images-gridview-from-database.html[^]

refer this from here you got sample source code ... :)


这篇关于如何从数据库中检索图像并在图像控制中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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