Click here to Skip to main content
13,138,372 members (49,435 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want to store/retrieve only image path in database not whole image in database.

thank you
Posted 22-Feb-13 21:30pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

use getImage to get file path as string and store path to your table

get file path from your table as string, then use ShowImage to show your image

Function getImagePath() As String
       Dim dlg As New OpenFileDialog()
       Dim StrPath As String = ""
       dlg.Filter = "Jpeg Files|*.jpg|All Files|*.*"
       If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
           StrPath = dlg.FileName.ToString
       End If
       Return StrPath
   End Function
   Sub ShowImage(strPath As String)
       If System.IO.File.Exists(strPath) Then
           Dim Img As Image
           Img = New Bitmap(Bitmap.FromFile(strPath))
           PictureBox1.Image = Img
       End If
   End Sub

chetankhatri 23-Feb-13 4:46am
thank you very much for reply
in which event of pictureBox1 i have to call getImagePath() function..?
In getimagepath there is no use of picturebox then how it assign to picturebox ,it will display in picturebox?
e9net 25-Feb-13 1:17am
as picturebox in vb6??
u can save string path to picturebox1.tag
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Store it in a varchar column of your table like any other piece of data.
chetankhatri 23-Feb-13 4:35am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Rather than storing the entire path in a single VARCHAR column. Try and store the path in a column and the file name in another column.
E.g:- Store E:\Pics\ in column1
and Pic1.jpg in column2
chetankhatri 23-Feb-13 4:38am
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

If (FileUpload1.HasFile) Then
                FilePath = Save_InFolder(FileUpload1)
                image = FileUpload1.FileName
                image = HdImage.Value
                FilePath = ""
            End If
 Private Function Save_InFolder(ByVal FUP As FileUpload) As String
            Dim hpf As HttpPostedFile = FUP.PostedFile
            Dim SavePath As String = "~/Images/Clinic/"
            Dim fileName As String = FUP.FileName
            Dim SaveName As String = Server.MapPath(SavePath) + fileName
            '--------------Save Image into  Folder---------------
            '--------------Save Image Path into Database---------
            SavePath = SavePath + fileName
            Return SavePath
        Catch ex As Exception
        End Try
    End Function
chetankhatri 23-Feb-13 4:42am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100