473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

add photos to a table

fnwtech
48
I apologize if this has been answered, I searched, but didn't really know what keywords to use.

I have a table of students. One field is photo with the type OLE. I have a directory which has all of the photos in it and the photos are named by student ID (which is the primary key field in the table). Is there an easy way to update the table to put the picture file in the photo field without manually adding each one? I have about 600 to do!

Thanks
Apr 7 '08 #1
5 1933
ADezii
8,834 Expert 8TB
I apologize if this has been answered, I searched, but didn't really know what keywords to use.

I have a table of students. One field is photo with the type OLE. I have a directory which has all of the photos in it and the photos are named by student ID (which is the primary key field in the table). Is there an easy way to update the table to put the picture file in the photo field without manually adding each one? I have about 600 to do!

Thanks
  1. What, if any, is the relationship between a Student's ID and his/her Photo Image? If a Student's ID is 123456, then is his/her Photo named 123456.jpg?
  2. If there is a relationship for naming conventions between ID and Photo, is it consistent?
  3. What is the Name of the Table housing the [Student ID] and [Photo] Fields?
  4. What is the Name and Data Type of the [Student ID] Field in the Table?
  5. What is the Name and Data Type of the [Photo] Field in the Table?
Apr 7 '08 #2
fnwtech
48
  1. What, if any, is the relationship between a Student's ID and his/her Photo Image? If a Student's ID is 123456, then is his/her Photo named 123456.jpg?
  2. If there is a relationship for naming conventions between ID and Photo, is it consistent?
  3. What is the Name of the Table housing the [Student ID] and [Photo] Fields?
  4. What is the Name and Data Type of the [Student ID] Field in the Table?
  5. What is the Name and Data Type of the [Photo] Field in the Table?

All student IDs are seven digit and the photo is named using the studentID.jpg (e.g. 1234567.jpg)
The table housing the student ID and photo fields is tblStudent.
The field name of the student id is StudentStateID and is a text field
The field name of the photo field is photo and is an ole object
Apr 10 '08 #3
ADezii
8,834 Expert 8TB
All student IDs are seven digit and the photo is named using the studentID.jpg (e.g. 1234567.jpg)
The table housing the student ID and photo fields is tblStudent.
The field name of the student id is StudentStateID and is a text field
The field name of the photo field is photo and is an ole object
Will get back to you on this one.
Apr 10 '08 #4
ADezii
8,834 Expert 8TB
All student IDs are seven digit and the photo is named using the studentID.jpg (e.g. 1234567.jpg)
The table housing the student ID and photo fields is tblStudent.
The field name of the student id is StudentStateID and is a text field
The field name of the photo field is photo and is an ole object
I think I have a better idea, one which you'll like. Why not store the Photos as Hyperlinks in tblStudent?
  1. Change the [Photo] Field from OLE Object to Hyperlink.
  2. Execute the code segment below, assuming your *.jpg Naming Convention is consistent as you previously indicated, all 600 Records will be updated with the appropriate Photo for each Student.
    Expand|Select|Wrap|Line Numbers
    1. 'Must 1st set a Reference to the Microsoft Scripting Runtime
    2.  
    3. 'Accessing Folder Properties
    4. Dim fso As FileSystemObject
    5. Dim fldr As Folder
    6. Dim fil As File
    7. Dim strSQL As String
    8.  
    9. Set fso = New Scripting.FileSystemObject
    10.  
    11. 'Creates an Instance of a Folder, replace with your own Folder
    12. Set fldr = fso.GetFolder("C:\Test\")
    13.  
    14. For Each fil In fldr.Files
    15.   strSQL = "Update tblStudent Set tblStudent.[Photo] = '" & fil.Path & "#" & fil.Path & _
    16.            "' Where [StudentStateID] = '" & Left$(fil.Name, InStr(fil.Name, ".") - 1) & "';"
    17.   DoCmd.SetWarnings False
    18.     DoCmd.RunSQL strSQL
    19.   DoCmd.SetWarnings True
    20. Next
Apr 10 '08 #5
fnwtech
48
I think I have a better idea, one which you'll like. Why not store the Photos as Hyperlinks in tblStudent?
  1. Change the [Photo] Field from OLE Object to Hyperlink.
  2. Execute the code segment below, assuming your *.jpg Naming Convention is consistent as you previously indicated, all 600 Records will be updated with the appropriate Photo for each Student.
    Expand|Select|Wrap|Line Numbers
    1. 'Must 1st set a Reference to the Microsoft Scripting Runtime
    2.  
    3. 'Accessing Folder Properties
    4. Dim fso As FileSystemObject
    5. Dim fldr As Folder
    6. Dim fil As File
    7. Dim strSQL As String
    8.  
    9. Set fso = New Scripting.FileSystemObject
    10.  
    11. 'Creates an Instance of a Folder, replace with your own Folder
    12. Set fldr = fso.GetFolder("C:\Test\")
    13.  
    14. For Each fil In fldr.Files
    15.   strSQL = "Update tblStudent Set tblStudent.[Photo] = '" & fil.Path & "#" & fil.Path & _
    16.            "' Where [StudentStateID] = '" & Left$(fil.Name, InStr(fil.Name, ".") - 1) & "';"
    17.   DoCmd.SetWarnings False
    18.     DoCmd.RunSQL strSQL
    19.   DoCmd.SetWarnings True
    20. Next


Okay, thanks. I will give it a try!
Apr 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Ralph Freshour | last post by:
I'm trying to code the ability for my users to upload up to photo's to mysql database - can someone point me in the right direction as to how this might be done in php? Perhaps a tutorial or some...
3
by: Dirk Goossens | last post by:
Hi! I stored the file name and path of photos in a table with data from students and teachers. Is there a way to show the photos in a report or form? Thanks! Dirk Goossens Vrij Instituut...
2
by: Ross | last post by:
Hi I have an application using asp.net that I am running on my PC. The web form has a text box where you can enter a name for a new Photo category then click on the button. The code is...
7
by: Eric Lindsay | last post by:
I would like to do a photo gallery with a liquid layout. I wanted to center a caption below each photo (or above each photo). I can do that easily with tables, but then I don't have a liquid...
1
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the...
2
by: el_espasmo | last post by:
Yes... I know the question might be stupid but... I still want to try because I haven't been able to solve this. I have been trying to change some stuff in MySpace, but not in my profile, in...
0
by: el_espasmo | last post by:
Yes... I know the question might be stupid but... I still want to try because I haven't been able to solve this. I have been trying to change some stuff in MySpace, but not in my profile, in...
10
by: K. | last post by:
Hello all! I have a question to you. I would like to create photo gallery. I wonder if I should store photos (uploaded by users) in database $data = file_get_contents($_FILES); $data =...
1
by: cumupkid | last post by:
II am trying to create a form that will allow me to upload photos to a folder in the site root directory and add the information to the mysql db at the same time. I have created two forms, one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.