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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Sending parameters to stored procedures vb.net(将参数发送到存储过程 vb.net)
Insert multiple rows, count based on another table columns(插入多行,根据另一个表列计数)
How to send to email (outlook) the selected items in SQL Server database using vb.net(如何使用 vb.net 将 SQL Server 数据库中的选定项目发送到电子邮件(Outlook))
datagrid checkbox writes Null instead of 0 (false) into database(datagrid 复选框将 Null 而不是 0 (false) 写入数据库)
DBCC CheckDb-any ways to detect errors vb.net?(DBCC CheckDb-vb.net 有什么检测错误的方法吗?)
one table is available in Presentation Tier, the other is not(一张表在 Presentation Tier 中可用,另一张不可用)