1 (edited by mathmathou 2016-12-09 21:24:02)

Topic: LoadFromFile and Edit record

Hello my friends,


MVD version 2.8


I used to use the LoadFromFile procedure to put an image in a dbimage and save it to database, and this works fine on new records.
It's done like :

try
     HTTPGet(URL,image_name,True);
     Form1.DBImage1.Picture.LoadFromFile(image_name);
     Form1.DBImage1.dbfilename := image_name;
except
     ShowMessage(ExceptionMessage);
End;

As I said, this works fine with new records, the save button is a standard MVD button with fields linked and no script.


But if I use a button with function EditRecord on an already existing record to which I want to append an image, the very same procedure does not work anymore.
The picture is displayed in the dbimage on the form, but not saved to database when I click on the save button.


Does it have something to do with the edit procedure instead of new record ?


Cheers


Mathias


PS : in the attached project, if you create a new record, use the Loadfromfile button and then save, the image is saved in database (just edit the record to see it). But if you first create a new record, save it with only a name, and the edit it to add image with the button LoadFromFile and save again, then the image is not saved (edit the record again and you'll see no image).

Post's attachments

Attachment icon IMG_TEST.zip 838.91 kb, 602 downloads since 2016-12-09 

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: LoadFromFile and Edit record

Hello.

just add this line
add_asset.DBImage1.dbImageIsChanged := True;

procedure add_asset_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
    add_asset.DBImage1.Picture.LoadFromFile('main_img_36015.jpg');
    add_asset.DBImage1.dbFileName := 'main_img_36015.jpg';
    add_asset.DBImage1.dbImageIsChanged := True;
end;

or download latest beta version and use this script
http://myvisualdatabase.com/forum/viewtopic.php?id=2888


procedure add_asset_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
    add_asset.DBImage1.LoadPicture('main_img_36015.jpg');
end;
Dmitry.

Re: LoadFromFile and Edit record

Thank you Dmitry smile


Is this'new behavior and is the latest beta stable enough to distribute compiled projects ?


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: LoadFromFile and Edit record

mathmathou wrote:

Thank you Dmitry smile


Is this'new behavior and is the latest beta stable enough to distribute compiled projects ?


Cheers


Mathias

I think beta version is pretty stable, but I can't guarantee )

Dmitry.