2014-01-21 132 views
0

我正在做一个程序,它保存并从数据库检索图像..我被指示使用varchar作为数据类型的IMAGE字段,我们需要使用文件路径来保存和检索图像..我做了检索图像,但我仍然对节约它的工作..使用文件路径在数据库中保存图像vb10

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

这里是我在检索图像代码:

Dim pathpic As String 

    pathpic = TextBox5.Text 

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

回答

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/

相关问题