如何在 SQL Server 数据库中保存图像的位置?

How to hold the location of an image in a SQL Server database?(如何在 SQL Server 数据库中保存图像的位置?)
本文介绍了如何在 SQL Server 数据库中保存图像的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用个人照片 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 数据库中保存图像的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)