How to Store Images in Your Database with Absolute DB. I've been thinking a lot about this issue but most database engines make it very hard to do. Absolute DB from componentace.com makes it real simple!
https://componentace.com/bde_replacem...
My gear...
My lapel microphone https://amzn.to/3RTEQCo
My boom microphone https://amzn.to/3RVoCZH
My professional microphone https://amzn.to/3QXWKmx
My smartphone https://amzn.to/3BrDZBZ
My webcam https://amzn.to/3QZvxQ6
My DSLR https://amzn.to/3LoXFLg
My video camera (4K) https://amzn.to/3BjQ2Bi
My selfie stick (with Bluetooth remote) https://amzn.to/3BT9ZR4
My headset https://amzn.to/3f1QLQ8
My earbuds (with microphone) https://amzn.to/3Ujpbhn
Button code snippets:
TDBimage
TDBImage control to display an image that stored in a database. By using TDBImage we can save and retrieve an Image to and from database. The Datasource and DataField property specifies the database field that stores the image and which will display in TDBImage control.
Properties
Center Sets image in center
Stretch Shows image in stretch mode
Transparent Sets Transparent background
Proportional Indicates weather the image should be changed, without distortion.
DataSource Sets datasource link
DataField Actual database field that stores image data
Events
onClick When user clicks on image
onDblClick When user double clicks
Methods
Picture.LoadFromFile Loads an image from file
Picture.SaveToFile Saves an image to a file
Lets check with an example
First I put a TDBImage control on form and set datasource, datafield properties. Then I used OpenPicturedialog and SavePicturedialog component to show open and save dialog to select files.
Load image from file to AdoTable image field and then store in DB.
procedure TForm1.btnLoadImgClick(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
begin
if OpenPictureDialog1.FileName is not null then
begin
ADOTable1.Edit;
TBlobField(ADOTable1.FieldByName('IMAGE1')).
LoadFromFile(OpenPictureDialog1.FileName);
ADOTable1.Post; //will store the image in DB field//
end;
end;
end;
Clear image from AdoTable image field.
procedure TForm1.btnDelImgClick(Sender: TObject);
begin
ADOTable1.Edit;
TBlobField(ADOTable1.FieldByName('IMAGE1')).Clear;
//or//
TBlobField(ADOTable1.FieldByName('IMAGE1')).Assign(Nil);
ADOTable1.Post; //will clear the image from DB field//
end;
Save image from AdoTable image field to a file
procedure TForm1.btnSaveImgClick(Sender: TObject);
begin
if SavePictureDialog1.Execute then
begin
if SavePictureDialog1.FileName is not null then
begin
TBlobField(ADOTable1.FieldByName('IMAGE1')).
SaveToFile(SavePictureDialog1.FileName);
end;
end;
end;
From http://delphiprogrammingdiary.blogspo...