Shady Level: VB Guru Registered: 08-07-2002 Posts: 305
Importing File Names Into DB
I need to read a list of files in a specific directory, then determine which of the files have already been included in my database and just add the newest files.
E.G.
I have a directory called C:CarDBImages
periodically I will add files to this directory, but the files will be viewed through a VB GUI, instead of having to manually enter the name of every image, I need code that will read the files in the directory and then determine which file names have already been included in the database (Access 97) and only add the new ones!!
Any Hints, Tips etc appreciated
Regards
Shady
____________________________
I don't wanna die... but I ain't keen on livin' either
20-06-2003 at 10:22 AM
|
steve_w Level: Moderator Registered: 18-04-2003 Posts: 1156
Re: Importing File Names Into DB
Hi Shady
To get the list of files , use the file list box.
Then to stop duplicates getting into your db set the field in access to "No duplicates" (thats in the index setings) then before you do the insert do an "on error resume next"
Thats one way of doing it
[Edited by steve_w on 20-06-2003 at 10:34 AM GMT]
20-06-2003 at 10:31 AM
|
Shady Level: VB Guru Registered: 08-07-2002 Posts: 305
Re: Importing File Names Into DB
OK so we have the beginning of a good idea here.
Now my area of expertise is controlling databases with code, I have not used a file list box since VB3, which is a while back, so I'm presuming we're using a FOR NEXT loop to systematically pick up the first filename, then cycle through the rest:-
if err.number <> "what ever the error code is for duplicates" then
msgbox err.description
endif
Next i
How about that one!!
[Edited by steve_w on 20-06-2003 at 11:02 AM GMT]
20-06-2003 at 11:00 AM
|
Shady Level: VB Guru Registered: 08-07-2002 Posts: 305
Re: Importing File Names Into DB
Thanks very much Steve
Much appreciated, as soon as I get stuck again I'll let you know
Shady
____________________________
I don't wanna die... but I ain't keen on livin' either
20-06-2003 at 11:59 AM
|
Shady Level: VB Guru Registered: 08-07-2002 Posts: 305
Re: Importing File Names Into DB
Just had a thought (it hurt too!)
instead of placing the filenames into a database and having the program update the content every time, I can use the file list box to select the images direct from the hard drive.
So 2 questions:-
1. What is the code for passing the selected file to the PictureBox
i.e. PictureBox1.Pic=File1.CurrentSelection
2. Is it possible to restrict the files displayed in the File box using Wildcards
i.e. File1.FilePattern = "C:ImagesAB12DEF*.*"
Your input would be most helpful.
Regards
Shady
____________________________
I don't wanna die... but I ain't keen on livin' either
20-06-2003 at 12:20 PM
|
steve_w Level: Moderator Registered: 18-04-2003 Posts: 1156