2014-01-21 135 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/

相關問題