Looping data out of Delphi

Hi : Sinisa Vuk brilliantly solved a problem for me yesterday where he helped convert a blob to a file.

Here is the code:
procedure TForm1.Button5Click(Sender: TObject);
var
  Blob: TBlobStream;
  Strm: TFileStream;
begin
  Query3.SQL.Text := 'SELECT docno, line, image FROM "blob.DB" where docno = 52215 and line = 1 ';
  Query3.Open;
  Blob := Query3.CreateBlobStream(Query3.Fields[2], bmRead) as TBlobStream;
  try
    Blob.Seek(8, soFromBeginning); //skip size??
    Strm := TFileStream.Create('s:\labels\images\test.bmp', fmCreate);
    try
      Strm.CopyFrom(Blob, Blob.Size - 8);
    finally
      Strm.Free;
    end;
  finally
    Blob.Free;
  end;
end;

However I need to loop the process for multiple records (removing the 'where' clause above), naming each file the docno + line from the table (both numbers).
I am sorry to be so useless but I am waving goodbye to my beloved Paradox  and Delphi seems best for getting data from db tables.
....and I don't know delphi!
Thanks!
Richard TeasdaleFinancial ControllerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
when you put:
Query3.SQL.Text := 'SELECT docno, line, image FROM "blob.DB"';

Open in new window

... then you'll get bunch of records....
Looping through them:
...
Query3.Open;
while not Query3.Eof do //while....loop
begin
  Blob := Query3.CreateBlobStream(Query3.Fields[2], bmRead) as TBlobStream;
  try
    Blob.Seek(8, soFromBeginning); //skip size??
    Strm := TFileStream.Create('s:\labels\images\test'+intToStr(Query3.FieldByName('docno').asInteger)'.bmp', fmCreate);
    try
      Strm.CopyFrom(Blob, Blob.Size - 8);
    finally
      Strm.Free;
    end;
  finally
    Blob.Free;
  end;
  Query3.Next; //go to next record
end;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard TeasdaleFinancial ControllerAuthor Commented:
Thank you very much Sinisa - again!
I promise I will not bother you again.
Sinisa VukSoftware architectCommented:
This is not "bother". We are here to help peoples... to find solutions or to expant knowledge...
If you get stuck ... just ask.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.