Results 1 to 15 of 15

Thread: [RESOLVED] Image path location

Hybrid View

  1. #1
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Image path location

    As RhinoBull said it's easy to accomplish.

    Link is in my signature - LOADING PICTURES FROM DB

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Image path location

    I still not clear with you post number #6, you create two field name. What is .\PHOTO ? It is a folder name? If I have image path store in the field "Gambar" like C:\PF\GUI\ancaman padi\PENYAKIT PADI\Hawar Seludang.jpg, So What should I insert in the field name I had created ?


    Code:
    Image_Employment 
    .\PHOTO
    
    This next one is a hardwired path
    
    ImageProcess_Master_AdmDuesCards
    F:\AdmDuesCards
    
    This next one tells the app to use a STORED PROCEDURE to get the image from the DB
    
    Image_Student
    ~GetStuPhoto_P

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Image path location

    Are all your images in a single folder?

    How many different images are we talking about here?

    GAMBAR is a field in what table? How many other columns in that table? Can you give us the table layout please?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Image path location

    Code:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Dim arBytes() As Byte
    rs.Open "Exec " & Mid(s1, 2) & " '" & s3 & "'", gCn, adOpenForwardOnly, adLockReadOnly, adCmdText
    If rs.EOF Then
        rs.Close
        Set rs = Nothing
    End If
    arBytes() = rs(0).GetChunk(rs(1))
    .imgImage.Picture = PictureFromBits(arBytes())
    rs.Close
    Set rs = Nothing
    I try to understand you code. How to start this?What is you table name?What is your field name?What the your field name data type?Do you store the image path location or the image name?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Image path location

    Gambar in table "Penyakit" , I have many column name..Field name "Gambar" contains Image path location .


    Code:
    Private Sub ListView4_ItemClick(ByVal item As MSComctlLib.ListItem)
        penyakittable.Close
        penyakittable.Open "Select * from penyakit order by id asc", conpenyakit, adOpenDynamic, adLockOptimistic
        penyakittable.MoveFirst
        penyakittable.Move CLng(item.Index - 1)
        sTarikh = item.Text
        Command43.Enabled = True
        Command42.Enabled = True
        Form18.getID = penyakittable.Fields("ID").Value & ""
       
        Text26.Text = penyakittable.Fields("Nama Penyakit").Value & ""
        Text27.Text = penyakittable.Fields("Penerangan").Value & ""
        Picture3.Cls
        Picture3.AutoRedraw = True
        Picture3.ScaleMode = vbPixels
        'Set Picture3 = Nothing
        On Error GoTo error3:
        Picture3.PaintPicture LoadPicture(penyakittable.Fields("Gambar")), 0, 0, 200, 200
        Exit Sub
    error3:
        If Err.Number = 481 Then ' jika tiada image maka
        Dim strImagePath As String
        strImagePath = App.Path & "\ancaman padi\NoImage.gif"
        Picture3.PaintPicture LoadPicture(strImagePath), 0, 0, 200, 200
        Else
        
        Exit Sub
        End If
       
       
    
    
    End Sub
    Attached Images Attached Images  

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Image path location

    Ok - one things at a time.

    First - you should not be storing the PATH and IMAGE NAME in the same field.

    Gambar should have just the image name.

    GAMBAR
    --------
    Hawar Seludang.jpg
    Hawar Bakteria.jpg
    Karah.jpg
    Reput Tangkai.jpg
    Penyakit merah Virus.jpg

    Since this is a "static" piece of information - it's what should be stored.

    Now the "path" should be in a different table.

    We happen to have a configuration table in our system - it's a two column table. It contains a "configuration key" and the "data value" for that key.

    If you do not have a table like this already - then simply create a table called ImagePath. It would only need a single column - and will only have a single row.

    To support your current path you would simply load into that table the value

    C:\PF\GUI\ancaman padi\PENYAKIT PADI\

    This would be the path your would store in that field.

    You would grab this path - probably just once when you app loads.

    And concatenate it with the image name from the field GAMBAR.

    Does this make sense?

    Now once you have this separation - you can change the value in the IMAGEPATH table at an install site to whatever you want.

    You can then think of enhancing this to support a value of:

    .\folder\subfolder

    When we load a path like that we take the .\ and replace it with the APP.PATH value. That's our "shorthand" - our trigger - that tells us that the path is not a full path but instead a path off of the APP.PATH.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Image path location

    Thank you all of you. I got answer. Actually I don't know how to store the application (app.path) in the database access. Now I found that it used like this .\

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] Image path location

    This is actually the line of code we use

    Code:
    If Left(strImagePath, 2) = ".\" Then strImagePath = App.Path & Mid(strImagePath, 2)
    strImagePathj is the string holding the file path to the images. We read that out of a recordset from the database.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width