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

2023-02-20数据库问题
2

本文介绍了如何在 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 数据库中保存图像的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

按天分组的 SQL 查询
SQL query to group by day(按天分组的 SQL 查询)...
2024-04-16 数据库问题
77

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

在 Group By 查询中包含缺失的月份
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)...
2024-04-16 数据库问题
12