I used Microsoft Access 2003, Field name "Gambar" contains image path location like this "C:\PF\GUI\ancaman padi\PENYAKIT PADI\Hawar Seludang.jpg" . When I create setup installation, there have default path location in "C:\PF" . If the user change the default location, the program will install the program to the user specific location and my program which used the image path location cannot view the image because the program install the wrong location. How I can make the image available to view any path of the location
Yes I know it, but I have to extract the files from database to the hardisk.. I have many image files if I store in the database and take time to extract the files from database. So I just used the field name and its path location to browse the files, the files already extract during installation to the target machine, I used PWD to extract the files.
It is posible to used app.path\ancaman padi\PENYAKIT PADI\Hawar Seludang.jpg" in the field name "Gambar" in the microsoft access?
Why not have your application create a new directory for storing images upon installation? Or the first time the application is run, or something.
I have include all the image in this folder C:\PF\GUI\ancaman padi\PENYAKIT PADI\Hawar Seludang.jpg" . So All the installation will put this image file in this directory
Code:
C:\PF\GUI\ancaman padi\PENYAKIT PADI
. It is a default. It it ok.
But What happend when the user change the directory during installation?Of couse the image cannot display because the path location has change.So I found that my program is dependent on image path location in order the user to view the image so how to make the program and the image can be view in whatever location user install my program. Can I use App.path?
We store our image paths in a table in the database
two fields - Configuration Item and Configuration data
For example - the .\ means to substitute APP.PATH
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
It's easy to create a method that allows you to support different options.
But the key to all this is to have the "path" stored in the DB itself somehow.
[edit] in case this was not clear - this is the "image path" - not the image name. If the image name needs to be stored it should be stored without a path - in a separate table [/edit]
Last edited by szlamany; Feb 11th, 2008 at 08:47 AM.
*** 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".
...but I have to extract the files from database to the hardisk...
Not necessary.
Few months ago there was thread started by szlamany so try searching through threads he started and you will find a solution.
We could not post all the code publicly because of a copyrights but it's easy enough to implement - everything you'll need (including links to third party) is in that thread.
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
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?
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".
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 .\