如何从sql server数据库调用文件路径但不显示它? [英] How to call a file path from a sql server database but not show it?

查看:164
本文介绍了如何从sql server数据库调用文件路径但不显示它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用字符串在sql server数据库中存储图像的文件路径。我想在vb.net winform项目中调用数据库中的文件路径,但不显示它,因为我只想显示图像。任何人都可以告诉我如何做到这一点?在此先感谢您的帮助。



编辑:



为了清楚起见,图像路径是从一个表单存储为数据库中的字符串,我想以另一种形式调用路径,但我不想显示路径,我想显示路径指向的实际图像。

解决方案

通过使用以下代码行,我能够解决我的问题。



 pbImage.Image = Image.FromFile( CStr (dtPersons.Rows( 0 )。Item( 3 )))


您只需将PictureBox控件放入表单并设置其ImageLocation即可'具有您从数据库本身获取的URL的属性。这将显示指定路径中的图像。



Ex: -



 pictureBox1.ImageLocation =  @  D:\SMRUTI \Projects\CodeProjTest\TestApp2 -Win\Images\chat1.jpg; 





希望这肯定有助于解决您的问题。


I am using a string to store the file path of an image in a sql server database. I want to call the file path from the database in a vb.net winform project but not show it because I want to just show the image. Can anyone advise me on how to do this? Thanks in advance for your help.

EDIT:

Just to be clear, the image path is stored as a string in the database from one form, I want to call the path in another form, but I don't want to show the path, I want to show the actual image the path points to.

解决方案

By using the following line of code I was able to solve my problem.

pbImage.Image = Image.FromFile(CStr(dtPersons.Rows(0).Item(3)))


You can simply put a 'PictureBox' control to your form and set its 'ImageLocation' property with the URL you are getting from database itself. This will take care to display the image from the specified path.

Ex :-

pictureBox1.ImageLocation = @"D:\SMRUTI\Projects\CodeProjTest\TestApp2-Win\Images\chat1.jpg";



Hope this will definitely of help to resolve your issue.


这篇关于如何从sql server数据库调用文件路径但不显示它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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