zerobro
asked on
Inserting JPG images to an MSSQL 2000 table
Hi Guys,
Given an MSSQL server 2000 database, MYDATABASE that contains a table EMPPICS
whose fields are:
EMPPICSKEY INT (not null) (Primarykey)
EMPLOYEEKEY INT (not null)
PICTURE IMAGE (not null)
On my local harddrive, say at "c:\emppics\" , I have stored here employees images/pictures (JPG) whose filename corresponds to the actual employeekey found on EMPLOYEE table which resides on the same database mentioned above.
Sample JPG files are:
1.jpg
15.jpg
21.jpg
30.jpg
Can anybody suggest a delphi 6 function that will take the images/pictures path as parameter, read all JPG files on this directory and then insert/add these automatically to the EMPPICS table?
Where:
EMPPICS.EMPLOYEEKEY = JPGs filename
EMPPICS.PICTURE = the actual JPG image
So it will be something like:
EMPPICS TABLE
EMPPICSKEY EMPLOYEEKEY PICTURE
========================== =======
1 1 (...)
2 15 (...)
3 21 (...)
4 30 (...)
========================== ========
If this can be done without using any 3rd party component at all, so much better.
Please Help,
zerobro
Given an MSSQL server 2000 database, MYDATABASE that contains a table EMPPICS
whose fields are:
EMPPICSKEY INT (not null) (Primarykey)
EMPLOYEEKEY INT (not null)
PICTURE IMAGE (not null)
On my local harddrive, say at "c:\emppics\" , I have stored here employees images/pictures (JPG) whose filename corresponds to the actual employeekey found on EMPLOYEE table which resides on the same database mentioned above.
Sample JPG files are:
1.jpg
15.jpg
21.jpg
30.jpg
Can anybody suggest a delphi 6 function that will take the images/pictures path as parameter, read all JPG files on this directory and then insert/add these automatically to the EMPPICS table?
Where:
EMPPICS.EMPLOYEEKEY = JPGs filename
EMPPICS.PICTURE = the actual JPG image
So it will be something like:
EMPPICS TABLE
EMPPICSKEY EMPLOYEEKEY PICTURE
==========================
1 1 (...)
2 15 (...)
3 21 (...)
4 30 (...)
==========================
If this can be done without using any 3rd party component at all, so much better.
Please Help,
zerobro
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
procedure TForm1.Search(dir : string);
var
sr : TSearchRec;
result : integer;
begin
result := findFirst(dir+'*.*',faAnyf
while result = 0 do
begin
if (sr.name <> '.')and(sr.name <> '..')then
begin
if (sr.attr and faDirectory > 0) then
search(dir+sr.name+'\');
slFiles.add(dir+sr.name);
end;
result := findNext(sr);
end;
findClose(sr);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
slFiles := TStringList.Create;
Search('c:\');
end;