Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

vb.net - How to hold the location of an image in a SQL Server database?

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Then save the result of ofd.FileName in your table. This will be the full path and name of the file they selected.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...