使用文件路径vb10将图像保存在数据库中

时间:2014-01-21 06:38:41

标签: vb.net image

我正在做一个从数据库保存和检索图像的程序。我被指示使用varchar作为IMAGE字段的数据类型,我们需要使用文件路径来保存和检索图像..我完成了检索图像但我仍在努力拯救它..

有人可以帮助我使用文件路径保存图像..

这是检索图像的代码:

Dim pathpic As String

   pathpic = TextBox5.Text

   PictureBox1.Image = Image.FromFile(pathpic)
   PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

1 个答案:

答案 0 :(得分:1)

基本上有两种保存图像的方法。

1) Store the Path Location of the image into the database and save the actual picture into a folder.
2) Convert the actual image into binary form and save it into the database. Retrieving the image from the databases requires you to convert binary data back into the image file so it can be viewed. 

您无法将实际图像直接保存到数据库中。方法1)更好,因为它更快。

这个网站应该让你开始方法2) http://www.dreamincode.net/forums/topic/182113-converting-imagelist-picture-to-binary-data/