问题描述
我正在开发一个使用个人照片 ID 的 vb.net winform 项目.我想将照片的位置存储在 SQL Server 数据库中.
I am developing a vb.net winform project that takes a persons photo ID. I want to store the location of the photo in a SQL Server database.
在项目中,获取人员详细信息(姓名、号码、地址等)并存储在数据库中.我可以做那部分没问题.拍摄此人的照片并将其存储在网络上一个驱动器上的文件夹中.有一个选项可以从项目中的该文件夹中选择一张照片,并将其添加到配置文件中.
In the project, a persons details are taken (Name, Number, Address, etc) and stored in the database. I can do that part no problem. A photo is taken of the person and stored in a folder on one of the drives on the network. There is an option to choose a photo from this folder in the project and it is added to the profile.
获取图像位置的最佳方法是什么?如何将其存储在 Sql 服务器数据库中?我希望能够使用照片的位置来调用它以在项目的另一部分再次使用.对这个问题的任何帮助将不胜感激.
What is the best way to get the location of the image and how do I go about storing it in the Sql server database? I want to be able to use the location of the photo to call it to use again in another part of the project. Any help with this problem would be greatly appreciated.
推荐答案
在您的应用程序中,您需要使用OpenFileDialog"以便用户可以选择文件.请参见下面的示例:
In your application, your going to want to use a "OpenFileDialog" so the user can choose the file. See example below:
Dim ofd As New OpenFileDialog
ofd.Filter = "*.png|PNG|*.jpg|JPEG" 'Add other exensions you except here
ofd.Title = "Choose your folder"
'ofd.InitialDirectory = "c:\SomeFolder..." 'If you want an initial folder that is shown, otherwise it will use the last folder used by this appliaction in an OFD.
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
'Something = ofd.FileName 'Do something with the result
End If
然后将 ofd.FileName
的结果保存在您的表中.这将是他们选择的文件的完整路径和名称.
Then save the result of ofd.FileName
in your table. This will be the full path and name of the file they selected.
这篇关于如何在 SQL Server 数据库中保存图像的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!