?
Solved

Pictures in DBF

Posted on 2000-04-17
1
Medium Priority
?
310 Views
Last Modified: 2010-04-04
how do you add pictures at design and runtime into a database(DBF file). Basically how do you do what the sample animals.DBF file does.
0
Comment
Question by:frangers99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
Motaz earned 30 total points
ID: 2725512
Picture can be loaded into dbf file using Binary field (BLOB) moreover you can load any file in this field. If you want example you can download my Electronic Book and Delphi book from my site:

www.gocities.com/motaz1

This is the example of my EB:

Blob Field (Binary):


Blob field (Binary Large OBject) used in Paradox tables to store any kind of data, including any file type. It is like a memo, (Virtualy there is no limit in size). Below example illustrates how to store file in a Blob field (Blob field in this example is called "Data"):

procedure TForm1.btLoadClick(Sender: TObject);
var
  MyFile: TFileStream;
  MyBlobStream: TBlobStream;
begin
  if OpenDialog1.Execute then
  begin
   try
    Table1.Append;
    (*** Save file name in a string field called "File" ***)
    Table1.FieldByName('File').AsString:=
      ExtractFileName(OpenDialog1.FileName);

    (*** Open the file using file stream type ***)
    MyFile:= TFileStream.Create(OpenDialog1.FileName, fmOpenRead);

    (*** Create the Blob stream and link it to the Blob field ***)
    MyBlobStream := TBlobStream.Create(
      TBlobField(Table1.FieldByName('Data')), bmReadWrite);

    (*** Copy all file data from the external file to Blob field ***)
    MyBlobStream.CopyFrom(MyFile, 0);

    Table1.Post;
    MyFile.Free;
   except
     on E: Exception do
       Table1.Cancel;
   end; // try

  end;  // if OpenDialog
end;


Next example illustrates how to read file from a Blob field:

procedure TForm1.btOpenClick(Sender: TObject);
var
  MyBlob: TBlobStream;
  MyFile: TFileStream;
begin
  (*** Create Blob stream and link it to existing Blob data ***)
  MyBlob:= TBlobStream.Create(
    TBlobField(Table1.FieldByName('Data')), bmRead);

  (*** Create a temporary file to extract the Blob file on it ***)
  MyFile:= TFileStream.Create(ExtractFileName(
    Table1.FieldByName('File').AsString), fmCreate);

  (*** Copy file data from the Blob to temporary file ***)
  MyFile.CopyFrom(MyBlob, 0);

  MyFile.Free;

  (*** Open the file ***)
  ShellExecute(handle, 'open',
    PChar(ExtractFileName(Table1.FieldByName('File').AsString)),
    nil, nil, sw_Normal);
end;


Motaz



0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question