How to print pictures with loadfromfile and filename from database?
Hello,
I have a database with books. For most of them there ist a jpg-file in a subdirectory of the application. the name of the file ist the ISBN with the extension .jpg
I tried to show the picture in a report as following:
- put a picture in the data band
- create a piece of code generating the filename
- fill the pictur with LoadFromFile
The code is:
In memo19 I print the filename for testing
-> it alway show the right value, but all pictures contains the same image (the image for the last book in the list).
What is wrong in my coding or report?
I have a database with books. For most of them there ist a jpg-file in a subdirectory of the application. the name of the file ist the ISBN with the extension .jpg
I tried to show the picture in a report as following:
- put a picture in the data band
- create a piece of code generating the filename
- fill the pictur with LoadFromFile
The code is:
procedure Band4OnBeforePrint(Sender: TfrxComponent);
var
  ISBN_DB, ISBN:String;
  i:integer;                       Â
   Â
begin
    ISBN :='';
    ISBN_DB := [frDSDruck."ISBN"];
    for i:=1 to length(ISBN_DB) do
      if ISBN_DB[i] <>' ' then ISBN := ISBN+ISBN_DB[i];      // replace blank with empty string Â
    if length(ISBN) >9 then
      picture1.loadfromfile('C:\Programdata\bisam\daten\jpg\'+ISBN+'.jpg');
    memo19.text:='C:\Programdata\bisam\daten\jpg\'+ISBN+'.jpg';  // test: show me the filename
end;
In memo19 I print the filename for testing
-> it alway show the right value, but all pictures contains the same image (the image for the last book in the list).
What is wrong in my coding or report?
Comments
Hello!
Try this before "loadfromfile":
Picture1.Clear;
I think "loadfromfile" command keeps the last value used.