var
sFileName: string;
tblImage: TADOTable;
imgCover: TJPEGImage;
begin
// first get the image if it exists
sFileName := Trim( edtPicture.Text) + '.jpg';
if FileExists( sFileName) then
begin
imgCover := TJPEGImage.Create;
try
// load the current image
imgCover.LoadFromFile( sFileName);
// next load the cover image to the database temporarily
tblImage := TADOTable.Create( nil);
try
with tblImage do
begin
// create the ADO Table, set the connection and the table name
ConnectionString := 'SOMECONNECTIONSTRING';
TableName := 'YOURTABLE';
// open the table and append a new record
Open;
Append;
// add the values for the new record
FieldByName( 'PictureName').AsString := 'PictureName';
FieldByName( 'FilePath').AsString := sFileName;
FieldByName( 'YourImage').Assign( imgCover);
// post the data
Post;
end;
finally
// free up the table
FreeAndNil( tblImage)
end;
finally
try
imgCover.free
finally
imgCover := nil;
end;
end;
end;
end;