Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I enable search?

Status
Not open for further replies.

dmarnerou

Programmer
Jun 12, 2002
30
CY
Hi,
I would like to ask how can I enable search in my Delphi program to search for an image on my disc and then save this image on the database I created using Microsoft's SQL Server, which is connected with my program.
It would be very helpful if you could provide me with some sample code.

Thank you,
Demetra
 
The function you are looking for is "FindFirst".
Take a look at the help file in Delphi and things will be clear.
 
When you save the file to the database you will have to store it as a BLOB. It may be easier / more practical to just store a link to the location of the file on the server.

Andrew
 
Code:
var
   ThisSearch : TSearchRec;
begin
   if SysUtils.FindFirst(ADirectoryName + '\' + AFileMask, AnAttributeMask, ThisSearch) = 0 then
   try
       repeat
           if (ThisSearch.Name <> '.') and (ThisSearch.Name <> '..') then
           begin
               ThisDataSet.Insert;
//               ThisDataSet.add some key field
               ThisDataSet.FieldByName('IMAGE_BLOB').LoadFromFile(ADirectoryName + '\' + ThisSearch.Name);
               ThisDataSet.Post;
           end;
       until (FindNext(ThisSearch) <> 0);
   finally
       SysUtils.FindClose(ThisSearch);
   end;

Also look at SysUtils.FileSearch; it might do just fine for you.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top