Hi Patrick
You do not need to use a visual control (TImageEnDBView) if all you want to is assign an image into a blob. You can do this in code using a memory stream:
// Inserts the specified bitmap into the database at the current cursor position
function TIEFunctions.InsertBlob_Bitmap(var ABitmap: TBitmap;
TheTable: TTable; AField: TBlobField;
sFileExt: string): boolean;
begin
try
TempImageEnIO.Params.SetDefaultParams;
TempImageEnIO.attachedbitmap := ABitmap;
Result := InsertBlob_ImageEnIO(TempImageEnIO, TheTable, AField, sFileExt);
finally
TempImageEnIO.attachedbitmap := nil;
end;
end;
// Inserts the bitmap of the specified ImageEnIO into the database at the current cursor position
function TIEFunctions.InsertBlob_ImageEnIO(var AnImageEnIO: TImageEnIO;
TheTable: TTable; AField: TBlobField;
sFileExt: string): boolean;
var
MemStream: TMemoryStream;
BlobStream: TBlobStream;
SaveFileType: TIOFileType;
begin
Result := true;
SaveFileType := IEExtToFileFormat(sFileExt);
if SaveFileType = iounknown then
begin
Result := False;
exit;
end;
try
MemStream := TMemoryStream.create;
try
AnImageEnIO.SaveToStream(MemStream, SaveFileType);
MemStream.position := 0;
TheTable.Edit;
BlobStream := TBlobStream.create(AField, bmwrite);
try
MemStream.SaveToStream(BlobStream);
finally
BlobStream.Free;
TheTable.Post;
end;
finally
MemStream.free;
end;
except
Result := false;
end;
end;
Note: Untested with standard DB controls
Nigel
Xequte Software
www.xequte.com
nigel@xequte.com